From patchwork Fri Sep 1 02:22:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719464 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp16528lti; Thu, 31 Aug 2023 19:23:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQDlzSVK4pUCpV5ra4u8ztpaRM6VrDcipNSlW6LZ+psUnaPzGr2qmtDNp4QWCFFSWzWiBg X-Received: by 2002:a05:622a:1646:b0:412:57:41b3 with SMTP id y6-20020a05622a164600b00412005741b3mr1687627qtj.25.1693535039168; Thu, 31 Aug 2023 19:23:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535039; cv=none; d=google.com; s=arc-20160816; b=M2DLleERyYeixwQdS08Jd9kjIOcnSGw/b4cdrVbSjCLGjOizPB+OFWTWUiJjSn/iwL ER+/AvxgM+e2q55hiGN/rlARp/5orWDHjBOirnk4/NPyOZz79yBsISRgPj1pqqsmQyfI DUaOlBOILZfTQNdsQcNcv6wvQ0GMAUGBugQ6f9zR7HAjkrmg+8RzHrqLga/AfTpj8wyL sIIM1GiM5xGwusCBmVTwkD9eogvCVL4VVTIMZarfoIWHG7UylAoeLykMGkByB1X1navR 0Af+2sXKkJTLqEUwryrxFX5k8QY8QEGmxRGZSXOZOzXawyQmC86VnZsnRu4ry3XcyF9A vj2w== 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=X0ddZs7bYg6jrh/HugPDxFYzx9+2rJ0wZJYAYZEah5o=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=ftiwFr4zmKGJIIExxa096KPKea1l7V0KeEhwPsifIyE1VCBahcTnKHwOdZ7GKWMLyx u8cgpYxRGETroAcbGg37t1hDiiFQoRPM2mrWl6I9jPmCBAeMxdru9fbHu5I7hY+Jh0yI SeX8mYeSYP6Cm8leNFWTaGVq60Qc9vl38eYoxEigChFMwufQxzAH7vSDCEWhNlzmXVGJ xgCZHNhmVsJCflbU51f9wayHWgVzS/3WP63cCahqtOdv9cf18JX8gOpsxEBcX/md3krB pUVlK23hU12ccFtKFqRKOGerMdRzQq0makBJYc0B2MTwiMYD0lD/TiKFakOYeRy45iKy SfGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=slvMMuLh; 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 h11-20020ac8584b000000b0040399b07ccdsi1685476qth.149.2023.08.31.19.23.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:23:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=slvMMuLh; 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 1qbtoy-0006TY-K1; Thu, 31 Aug 2023 22:23:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtow-0006SE-Cc for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:38 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtot-0001Nj-Hu for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:38 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-68a529e1974so1171855b3a.3 for ; Thu, 31 Aug 2023 19:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535013; x=1694139813; 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=X0ddZs7bYg6jrh/HugPDxFYzx9+2rJ0wZJYAYZEah5o=; b=slvMMuLhNqib2zcWsTXMFpycln0Psey3QkDLkdP2GSpZUp/JWNlhlydrcJDGcl9T1e QcHKlU7EZZXd8mA9xfmzO7uj30QEbrrqTuBIwyeZe2K5nnpyuPS5iY71hQEcK4Ionmzi vFJJo6dgu5+Pampx29XqPxM3XuWHu+Vl7mhnYH2KsdzzBw7za+BKIakJ4Y9SdrDTzv2F 23hqRW0LeDep2tWfN8efSznvUpAiVybpubz9+B9nQnNwO9XPMCLU2vH3LvohI+JqJjNe CaOhbhnDlpyGMQl7s1OR+mr/6AHap9arDpJDfitulzG7SGFpbMDAdsybYT101AK/SJ8a FeiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535013; x=1694139813; 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=X0ddZs7bYg6jrh/HugPDxFYzx9+2rJ0wZJYAYZEah5o=; b=JsswbJEfJRn1V4embR94W1vOeTi0MOotFrvZX+1p8MWp3o4cMUOrDIGm8p2ZOojiA8 sOnzRQ7REfTyexZSqFW4t43seRNP9XFX+wyRJdwF4+/IOFFQTD7Opw2rNLStvEp+scSd r/rmnh/ex2PkODkBZz/lESUuJ5ptHt4FEw3awj4xA9iTZV9dmvHcl/l5IlWJq7OGsFvH +6k78BsDKwLj56ON/NqXoBhBMD1bU3GiXKliXJp+8l5NU7TMulowHO6O8ktRJZ42i8lh 7XwlOk91mH3rUFJMWVkaqQD0lX35Bblh6JEUKPSOfpcKF3TA6P4TP1PpWEkhCV7de4hP I3Pw== X-Gm-Message-State: AOJu0Yz7dimDJt2js7p5xjcgdhnLcd05Z627Z18umDo9bBQH8Lnpybj0 XUMOj4mKF2Jy2GkjRYVlMLLLPlc7M7QVx8HH46k= X-Received: by 2002:a05:6a00:1a87:b0:68a:5395:7aa9 with SMTP id e7-20020a056a001a8700b0068a53957aa9mr1717296pfv.6.1693535013189; Thu, 31 Aug 2023 19:23:33 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 01/33] accel/tcg: Remove qemu_host_page_size from page_protect/page_unprotect Date: Thu, 31 Aug 2023 19:22:59 -0700 Message-Id: <20230901022331.115247-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 --- 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 ab48cb41e4..4c1697500a 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -650,16 +650,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); @@ -670,7 +671,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; } @@ -678,7 +679,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); } } @@ -724,18 +725,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 Fri Sep 1 02:23:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719497 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp18092lti; Thu, 31 Aug 2023 19:28:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEkDF3ooHoGc2RyhdgBoehphlIEmgA52FNyxNhU3GJ9GoG2vzsEiNKM1ew+Ef9HsK7Z/BQ8 X-Received: by 2002:a0c:f3c3:0:b0:64f:3ac9:4bb9 with SMTP id f3-20020a0cf3c3000000b0064f3ac94bb9mr1007464qvm.5.1693535314389; Thu, 31 Aug 2023 19:28:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535314; cv=none; d=google.com; s=arc-20160816; b=QWLmpoTliuV/+Fk9V7LrQ6LceshWkyJ1kkA9INN1IQ/OJwHyslC9rcurA0MLEsXUuE yYoKqj77ReGQEVIhveOIimP+0onJHsa2t+MbrHRUH2OfN443WM29+K2bBvU2p5ZGh/Tz 9j3yj4U6RwYFKHojwerrSKbJNVPJjlKyhsPCjmHdf9cOBSAqVD4AmtKFchXtAa72k9tH F2WvkYTujHyMLlCwSLYpc9O7AxRlICzFzuCDHFIxwpjKcb7GX3AjKD5NPIVBBq96ex9r KXRliMfnNdeQ6oUr+snjOtEXAiEet6qlu0e3nzzduPvOPQ8l/M9CheylxHr24GHR33tB BUtw== 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=Ig/BU1p5rBUclrU24B2APEaCZb1m4+3FwcOcSczB0lA=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=QYiJsxxQ8waqzvYxJvpugeHfcjKg9McsyWL9RJfsvlS8yMWPiev4c6/seX+MSPJVOR Rzu2sB41b1ZrzdLdY/CHz1IyKKTvocmO6y2ZsAF3Mt1jsicGksqw/kMmUY0c7UUo3410 hoUZx0lJKxdk/g0UZvYNxQw+n+EXFZjI9z58LBFqko92WiAqn0+5734XsC4VRTcksetw 4hc+wvU+XNS1GTuC5T6lKyGHWDA1dC9sWCjxe1wEoCQEAI4Bh+qOyoX+wSKErdt2iXzm Wh2JYLDzIDytshc/ze6AtQkHaZX8gVh/HYa2hRrzwPxxOXhntKap8phJm8nEv6hQJC65 my9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FVqRnsBd; 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 p17-20020a0cf551000000b006300516b58dsi1739775qvm.185.2023.08.31.19.28.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:28:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FVqRnsBd; 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 1qbtox-0006SN-0D; Thu, 31 Aug 2023 22:23:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtov-0006Rx-PN for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:37 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtot-0001Nr-Hk for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:37 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-53fa455cd94so1137382a12.2 for ; Thu, 31 Aug 2023 19:23:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535014; x=1694139814; 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=Ig/BU1p5rBUclrU24B2APEaCZb1m4+3FwcOcSczB0lA=; b=FVqRnsBdrlE+cAAcEvzLGzyK4LxUVuWmMOdMYtbN93MN/G4Tsa/PI6vD9gH4RN1sUR l9e4PKEvaZUxer8jup9ESG4+5zX1lvEXqoAzKmiCz5+TUPeF31uQaA44aVK0ZaFSTo6k CjFJo1RDYTbHiqHbhpeJxe5YlmXNbnkxMujq/OgWwOJBJMvA8y4tSz6UBc4WdZZlHkmq iCozjbD8j2Ti5Wvz2d7ez7neYcIk9vLALYbFRGcvssKGoaLiptE7dlSst+dIvpAcdlLU FrgRkcwuc8M+qxMgu9I4jjYupzf0jPcVkq4vFOEKtiqXkKH0+4Ct0GXqqfuUe7JC2U/H e0NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535014; x=1694139814; 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=Ig/BU1p5rBUclrU24B2APEaCZb1m4+3FwcOcSczB0lA=; b=WVb4DWX9dRPgxmLBoYpeFvcRpcVGUHvKtm2CBdh1gQRMszUEzLl4q4JUSg2MCzN389 B2MQ4sCqSZ5un85bk8WAHU7+bIsBDa9TKsrk+po8d0Z8qFXqH4hzQN42zp521iy46Rxm rZA+Kl/Ijy+nT9fM+zCo5uZ3hukZrNSMz3Zg1MRzmTM47jXd175WT9fqm4d7XnRqiTH7 Xx5ky2Yl8SM20rzWkdczDs8QeHh5jR1GmclSIPWzmqxuB9JQkYx+cBBF/9t/GvnzoZ+m UYThwXj7OuPyLtsuPh8Y55FbtUer73H2PROJE+CDbv99d/nRrlp/EMq6vyxldOncd1W/ Kx7g== X-Gm-Message-State: AOJu0YwDQ1mERFPm/vRd98gAw+3Z7sdNtgYEm0yraMpYL0ih8HbsujwO LuFA9pDLhtbtwAFzRwq5m3+7ZsUYsFyPXxaorxM= X-Received: by 2002:a05:6a20:440f:b0:132:79da:385a with SMTP id ce15-20020a056a20440f00b0013279da385amr1995020pzb.23.1693535014208; Thu, 31 Aug 2023 19:23:34 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 02/33] linux-user: Adjust SVr4 NULL page mapping Date: Thu, 31 Aug 2023 19:23:00 -0700 Message-Id: <20230901022331.115247-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 --- 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 19503d8469..803281a53a 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3730,8 +3730,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 Fri Sep 1 02:23:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719484 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17385lti; Thu, 31 Aug 2023 19:26:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEr7KZamZVAjQ4VYiU/e0VoE+2pNulMMjvfPHN3Mj+t9yfyLV+EgH25tjDbO04an/3+O50N X-Received: by 2002:a05:620a:2592:b0:767:f1e8:d38c with SMTP id x18-20020a05620a259200b00767f1e8d38cmr1303739qko.15.1693535191141; Thu, 31 Aug 2023 19:26:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535191; cv=none; d=google.com; s=arc-20160816; b=YvdMHzd6MFRvjbxU2CnOnUSA2mgA5vuo1hrI2HIwggvxQ/4a5EkNkVDOZRevkRzEjS TOqCk76qwWnxl/vXt28E7k0L+GpJlikgVZrMEC8oGr0y2lf6sHzGfKB0OtO2i2apqc20 momFkGKvOtfyXUdQ8v+T6lXVuRUFAeu9wJ/EdcaHXQGfxGdKa60kbLVaf6QowTFhkJoy ydHvQW6YFSRlgme30SV7nZ8UIQjsWwqvSqy6BLXkPc6xz0CnUy+UPYqs/JbsQKpZP1dC uMraOMbzesHsIQ3zG4U5yPD5kQt16VeVOnma2Te7dlZVoDuJO1ZZR3PXUVlptab9n98w WrYA== 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=C0v5Ti5rtUv1bybp9Gg5g/SRQF/P2TUzqcILBLMIhF4=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=XG1+KAtnM55dCSyj+jV+VNUMteHiIli8FN3EsYnGaK5C+n/rbgZLLBuiFp82j28evz dmlAzSv7lRE0/9fq1fwUb+lP3T7+oFLNID/lbVb9M7GLoBEeNTkClzcovvtREQR591d3 8LJSCO3i7MvCJYRnh/bOGleCwiKUUV1wcONEAaGP/vJNEQa5l8JCeHQzfCQXLddyqhc4 BQnG3+A9AZQqFAusWKnpCPEeCYiTVRUP1VicBe/em+v0EPGNbf9nFlp7YIAN2vdjmwtv Mta+kUmQoc18/nd2Zj0XRphunmo5rsTmfri+FGBLfTxiueMgHHFr2CSx7T568Q2kLVqg 3Tmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PlkpcrVH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k16-20020a05620a415000b0076f2c0f9dbesi1875755qko.512.2023.08.31.19.26.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:26:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PlkpcrVH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbtoy-0006TX-JE; Thu, 31 Aug 2023 22:23:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtow-0006SM-Tg for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:38 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtou-0001Nx-Lt for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:38 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-68a56401b9aso1248109b3a.1 for ; Thu, 31 Aug 2023 19:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535015; x=1694139815; 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=C0v5Ti5rtUv1bybp9Gg5g/SRQF/P2TUzqcILBLMIhF4=; b=PlkpcrVHz48OUlKwgK7v8YJ9XMV5S6bSGVquvo5+qwi8vJYwdlpIPzbiDe6YfrYmZ9 0/3wwApUZ7hlTLbOs8FqxMQ1DXqPF243dTY6QjsW7lG4x27C0na7bKovAB41OjjeTKHF UH1Tc/5vn6cxpVKjN6bx3aMinjIXfqSScZ9OewjE2jO3p7sCJdLInLpgUOC7b5O51CGE XB1Duw0XxsQzkuATLuBLoSzC2q4wSNSoX+q9WPNJjsEBIvjCHpMFAIJmsoN1omoeVBMZ cRGTRYZqPQ0awvjYzc8Qz8Nz9uBRX2aRYtje5yLKXLwFOhQxG/s02qDNbGxSSWSzzCKt CREQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535015; x=1694139815; 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=C0v5Ti5rtUv1bybp9Gg5g/SRQF/P2TUzqcILBLMIhF4=; b=co3IAmdqvPZmPj1dmSdBdPqqVYOsToisNBpn4nvYHjCcw6FCRY02cSgGHIkhiuB9yC XD09ozq0ow49nBm7qONK4EmdFuL/xLVpiH5ZPl+28zGTmxktfDZn0LtqqN+fFCX1mcGd glF9Ns85QsBugv+hDUWPvHEmGNivHT8l0O6WF1UB7Evca7PxYkfbIhePadYHaSoDexf6 a8E0MSVMUAp6RRKH2SjlB7tz/McQKy+QYgFQ93iRuktl2fAIGIx/zJE21E4Xdc36RnAq P353HawHAwvo4RMCm5jMVX3nthqvT6izdPIVw1i/qnSB9ECRqjjVRXuWJbUNP2bdUh00 w/mA== X-Gm-Message-State: AOJu0YxjprENpgSVp7C9XStFWKsCmPGpblRFJqDQjeZIPzrPfGq/FrFL 8p8i7RaXIJ8XAzvJNep7+5N9Dloq98qU2dq+jiY= X-Received: by 2002:a05:6a00:1a8e:b0:68c:3f20:5e8b with SMTP id e14-20020a056a001a8e00b0068c3f205e8bmr1891149pfv.15.1693535014979; Thu, 31 Aug 2023 19:23:34 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 03/33] linux-user: Remove qemu_host_page_{size, mask} in probe_guest_base Date: Thu, 31 Aug 2023 19:23:01 -0700 Message-Id: <20230901022331.115247-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 --- 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 803281a53a..7851003147 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2712,7 +2712,7 @@ static bool pgb_addr_set(PGBAddrs *ga, abi_ulong guest_loaddr, /* Add any HI_COMMPAGE not covered by reserved_va. */ if (reserved_va < HI_COMMPAGE) { - ga->bounds[n][0] = HI_COMMPAGE & qemu_host_page_mask; + ga->bounds[n][0] = HI_COMMPAGE & -qemu_real_host_page_size(); ga->bounds[n][1] = HI_COMMPAGE + TARGET_PAGE_SIZE - 1; n++; } @@ -2894,7 +2894,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 Fri Sep 1 02:23:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719472 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp16883lti; Thu, 31 Aug 2023 19:25:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH2lwtOegMq6ED6w7eDkyS1fTUVfWfjRKuwmy1pFRu9ATWLRw/U240jlY8UVEqyuWkBOu5g X-Received: by 2002:a05:622a:64e:b0:410:9af1:f9b2 with SMTP id a14-20020a05622a064e00b004109af1f9b2mr1679062qtb.3.1693535099887; Thu, 31 Aug 2023 19:24:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535099; cv=none; d=google.com; s=arc-20160816; b=dtPOOZY8oidfNPMTzD2K91zlJl4HAIuwUfKn5oFpTsU/k41Auv0wwL8/dhoX6TOtTB RfKsJzMm9Jmk7cd/t4vH0tsUae4+eq1feuSEZhYudC65s/5FHZOuSfZv+SXi7SRKVNfa Jjs96cSx8zSsyjLix0ckPqdBlSvNNa0lj5SzOBzEabBRzh/FQ3reBeWVwl7YgtCtYpWv HC/d4Ao+Sbt6uHGle/JF8g3v4pd71Un5wzFLdjtbXiSnw3sY2Za8ixywfk0XTqLrGkW5 4nW0CRRD+gQb9xPBgUeiPs+1U8q1ND70/9Ai11E97IhQmeqeA9/MNWxFlhi8nk5NcHCS wC6w== 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=l1Ia6H4r6/UDLfCIgaKhnJIkJDHurCCHa2efkMKJruA=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=Xrt/UUGsTD7Bg0zqM7mcE9EVw8L2cZnk1FMl3LtTKswb5CpMrFYUtfFqWSdVobAdSW FFA2Lv3/Mvnjyj0JQ626SxDtiA1XEL5KIFrBbYVzFApP5iwlFU/zSBG/JVsjpQok3AWT JQmLgEjL0QPqK2jFiyLFQjSmNFMuif3X7rSPIYLWPAMPpiylp/GcMhbFjDmZPhJOaAUy cTMt+3hMF2+WSOra2pz61zpO1OODERGtqmwyDqg1iwt4hPLFWFl3iNlc9SL03xZX1AvZ aDhe1E0O/gBC+22ynlfR3jZS13sbg99iFkEzlzNjKkg7SVQFY5RnWRoMnP1Vw7xfdM3y sYcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u3Ojsx1Z; 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 a22-20020a05622a02d600b0040335d4e09bsi1724602qtx.19.2023.08.31.19.24.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:24:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u3Ojsx1Z; 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 1qbtoz-0006Tg-6F; Thu, 31 Aug 2023 22:23:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtox-0006Sn-NA for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:39 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtov-0001O2-2u for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:39 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-68a3e271491so1099143b3a.0 for ; Thu, 31 Aug 2023 19:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535016; x=1694139816; 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=l1Ia6H4r6/UDLfCIgaKhnJIkJDHurCCHa2efkMKJruA=; b=u3Ojsx1ZXD6IVEVCqXqvTn0O/PZHORG75p6wWJm961yqH3STGeebqV8V6B7AI0NP3C IHTP67pUF8PrtFpFQGbmw9HmEtvVvGYh2JjMxPsPYIJD+fBVppv7NpSEKa/4hrnJvmH7 2JB0BzFHfOXjipUNs2QTC9E1OSAG7nTAJvlvemBhpvzhdu1jfq0/ILu+qIQkvryVl54x Phfdkh4D0mYDt7eUdma6hqMQaHZ6O0FgJs7HxaKrBD0Qiqgc3+3XZHlch7RDmzUI2yUH u8iuKa4yMKxkqXN8Qv4+JpjePaSo5KqPqusoinP0L7nQRgAaEVZesrUfg728StOLnbe4 pWDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535016; x=1694139816; 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=l1Ia6H4r6/UDLfCIgaKhnJIkJDHurCCHa2efkMKJruA=; b=QywVY0XYqn4ys6aDZIlVo1veQNxtZICXmv8QVnx7gdsiFTvQmA6QqQsPO5GRafSsjP /Gdl/8/xipqyeVtbWmg5RrTKJ01U4AoAdu37ruA0xV48P8DhCipN5tZFnDqLZBJtW0ea MtIix7Ajf0aFuyF3CuqjWtjgoXTIY8mIlAaWOSSI3+k6wyS1SuTGfh1UDV+3kY8NwtU+ 31wzsmP/ts/uMoG1aTZVCuvjKa1vTsdcSq5FB7KxqgWQvSO2Arh/Ef22QFj5PEfUX8GS OWCFGS+fK8ZghUCUGfBKQ7Cmbpgp2yRGd4VfLVMxq0Ezguuz8Py+x7D3GBNJ/HOMFpEw GI+w== X-Gm-Message-State: AOJu0YwLjoIwUCc67NPrAfT2l7KKDh2eGfPW+hwWRjcxaGfpFHM0UzdU R/sVeWOteOPLgdAaksUWUMOGOjSjjWtTRWQZeGE= X-Received: by 2002:a05:6a00:3985:b0:68a:3b25:50d2 with SMTP id fi5-20020a056a00398500b0068a3b2550d2mr1529427pfb.14.1693535015739; Thu, 31 Aug 2023 19:23:35 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 04/33] linux-user: Remove qemu_host_page_size from create_elf_tables Date: Thu, 31 Aug 2023 19:23:02 -0700 Message-Id: <20230901022331.115247-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 --- 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 7851003147..885566c798 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2498,13 +2498,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 Fri Sep 1 02:23:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719478 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17086lti; Thu, 31 Aug 2023 19:25:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRYvjbxVDAMcuf6ALywyWVpsUbsXetydSgE3XLeSfmsrNl+Cb8OXYUmsp3NODUjGOTQN1p X-Received: by 2002:a0c:f193:0:b0:649:914:6495 with SMTP id m19-20020a0cf193000000b0064909146495mr1041121qvl.62.1693535135710; Thu, 31 Aug 2023 19:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535135; cv=none; d=google.com; s=arc-20160816; b=w12CDB1yThgPQgQfNOaYHsaFiHFgCdv49Qzgr+OnyPGPWJDvdb1TSjjZC1jJDuO/Wz RfycOk+Im2y7l6/AB9a9VYZi3atlispTR96Ugy4NX0e43MSfhLNivc6GXgWty2E/Nsn/ fD1Yq0T5FPNNjcnImB/y9mrcQ3DEdL1B92B7/hYoYxNGuCicsIqM1bKors28WXT4bNTq zYF9sgSwS9g8SiCwrjmzAGzD9vNNtj2mWUSXM21s0quUijVGEFYhTJ+MtoSPJquin+qE bt1qxGzOL5aG2dKnX6fnV5arLhdFcOEQtT4N7A3RmjP4MjaYiuD2TrzrwfkNcnuLHsHY 5Q4w== 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=3P9EWl1tJVitUp2HhYjFwCQR4+GDFyi+Ud4oCYb+o1w=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=RbyMcclRQhvi4AxQxQspw7WxaexYeWZ8D7eNsk0ffu4jROrH4VrtlOM+F+X9S1CwP9 B3P2wIRhT0g8JdNlL8fffbn8ny9vawkIyDFWLLWl3SV6Vu+75VoKfBVU6AYHPE0chN1l x+4MjhoML6L63Zg5FIGjjBHDQsggPrPWVpF/YaYZpxvES/0fbEoyarpyaJGKYdsfHxWA xioHSppUjI19lnS6x89mBcAbWmmAj/YLc0BxOmNC1i7r+0rUbAocbMCfxF/Iw9zBVMYa Gwr2W/brpeaSWXcFXNjdhy/7WHBLeUmqrsZ1UD4G1MsjcqTrDY5nDlGUPfzz943ZC09C XZ+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="B/oA+yTs"; 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 t3-20020a0cde03000000b0063d453959fesi1770644qvk.369.2023.08.31.19.25.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:25:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="B/oA+yTs"; 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 1qbtoz-0006Tw-O7; Thu, 31 Aug 2023 22:23:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtoy-0006T9-6X for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:40 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtov-0001OE-Tv for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:39 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-68a41035828so1182246b3a.1 for ; Thu, 31 Aug 2023 19:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535016; x=1694139816; 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=3P9EWl1tJVitUp2HhYjFwCQR4+GDFyi+Ud4oCYb+o1w=; b=B/oA+yTs3oM6YKSyum0INh9zx8bBLMRuuL3+qa40XYle9TdovYY/CsGO6EfNHv8YHD beK4afvtISr2ElNhk+krN20aRjPiEjaWz53N+aM9InqMqTW/Th10II3akXBNWlJMJn2C jDaFHKI7ART9ds/vOrUQ3qBR3QBLfgTXpJhsZmiF1BPozRFkJBF92sKH/GClwvptILOg o1gVaEqw9ENiC4SrOA7yPoUvy63VbUkl/075dA8QHQzOc2aOIT5fMU3DQNqvtBl3AjZL eKKYwzA/3HDKsv6LNJCHyJpfoNakA0EnnlNY34cJQMCmIFeoMH0n0bWytx+cFAOMI5sr x2wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535016; x=1694139816; 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=3P9EWl1tJVitUp2HhYjFwCQR4+GDFyi+Ud4oCYb+o1w=; b=j19lQGHYq6eccR4wAWRP8BF7xfN/69UZgOtz+/opc04UYnmBqUY9gsKgBjZAckaZ9x yqRAYVVNG5X0auY8lQy2eHvz1EFAjm0Op2nAaScSC0Eh3L8ijcRABeavWGj8eQDo/vUa jTQuqXUQ5euk8FUlZxUusnpqC6iIFVV87yVPSKKlu1JJzlsbYqEun9BUxRGWACrL2Mcl sTFLogwaZj5RUT+1/EZeoyggqA4WZ9BSN+StLL4sy+hKEBursHhRD0XJ4tHKsDPyriNg xjmeBVMazNJ2Ysa0dNApbKoqYI31pa65a3R3JzqqhTaDLA1rNPbiIPBLY1NC7vfXpuT4 mlBQ== X-Gm-Message-State: AOJu0Yyd/q8J3K1mFfOX4XU/b961kbgyWWjvWW0tHO9z590yWRmXqGAV 54YOKCxHC+xnSuMnjSfQusjEm71bWZ0kyvhuxD8= X-Received: by 2002:a05:6a00:848:b0:68c:478:de31 with SMTP id q8-20020a056a00084800b0068c0478de31mr1581083pfk.12.1693535016518; Thu, 31 Aug 2023 19:23:36 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 05/33] linux-user/hppa: Simplify init_guest_commpage Date: Thu, 31 Aug 2023 19:23:03 -0700 Message-Id: <20230901022331.115247-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 --- linux-user/elfload.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 885566c798..939c9b4df1 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1812,16 +1812,21 @@ static inline void init_thread(struct target_pt_regs *regs, static bool init_guest_commpage(void) { - void *want = g2h_untagged(LO_COMMPAGE); - void *addr = mmap(want, qemu_host_page_size, PROT_NONE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + /* If reserved_va, then we have already mapped 0 page on the host. */ + if (!reserved_va) { + int host_page_size = qemu_real_host_page_size(); + void *want, *addr; - if (addr == MAP_FAILED) { - perror("Allocating guest commpage"); - exit(EXIT_FAILURE); - } - if (addr != want) { - return false; + want = g2h_untagged(LO_COMMPAGE); + addr = mmap(want, host_page_size, PROT_NONE, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED_NOREPLACE, -1, 0); + if (addr == MAP_FAILED) { + perror("Allocating guest commpage"); + exit(EXIT_FAILURE); + } + if (addr != want) { + return false; + } } /* From patchwork Fri Sep 1 02:23:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719469 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp16772lti; Thu, 31 Aug 2023 19:24:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuaRr+1NjTwFHVonB4p6hs9eITRCYUFCW+wsDYvFptM0menpmyR4n9b7CS6jPHdFmwaFpa X-Received: by 2002:a0c:de11:0:b0:63c:fb1b:6bb0 with SMTP id t17-20020a0cde11000000b0063cfb1b6bb0mr971038qvk.52.1693535084040; Thu, 31 Aug 2023 19:24:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535084; cv=none; d=google.com; s=arc-20160816; b=As8B3+/rUkHTzK84zV8mLfRh6kQbRNg0F5doeKaUjgHZo69Fqpdwo4taATx1KMqucr MZIGUmCphB4d0vNtqjQpMhN9ymr5XYW0+QINPRr3wOZs4FjorC1JWATIT7/KpruSw1Jw dzfE7peg/YhgPCXQhrWbAo+KpOJlOFgrm2msRdsVc2vwTOEpcOSoqFfFDz4LuHO2CKWH K2Hb0huvP83XGHddE7bJOaMId/GTbX6TYa58CvFHVUQGR+iK5oazLVuKMTPk2bysxLYc cZDsGfxti6c7gcQvjgKmb00qwmseyGtbkURnheUaSl8jcm5T8bfNwgGmWZbSgeuE8htx Ll2w== 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=nu15p4NzoIMDD0853qBh0z3WcT+BzXtXp1Q+7rXZXJc=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=v7fVeQmYVa/Y8GjfX6PhCXzwQmTGJ57mIViQYY4OsBfF+dPr0KDWMX8inYbgN7ithZ 6RwNMnTFb33rSMY1qkTDdRCu0DC442bySfp9i4qzQJscHuM3AweeBtFi9y9J/YEM+pp1 mUaojtzmRvvgPaf82Brd0yjF8Os+A7eroowGqMbrymh7yOaT3GlYTS/7A6OZHqbVkqSV B71EIBVO1SKFMYc0KRx+S0cUMDI/45eibSoQQs3wz0oJKZliCgm0yCLiBYykjpCVryS9 2Mx+Ia3kc5BnX1HF4pIbOa03fNSDw8V4jSxaWxYzNuOpnwUGj4LM9Tw/5fiQ3JECVw96 VSYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gBMSqB8q; 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 bm39-20020a05620a19a700b0076da64decfbsi1831929qkb.63.2023.08.31.19.24.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:24:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gBMSqB8q; 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 1qbtp1-0006UL-9r; Thu, 31 Aug 2023 22:23:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtoz-0006Ta-0d for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:41 -0400 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtow-0001OS-QD for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:40 -0400 Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3a9f87adfe1so972085b6e.1 for ; Thu, 31 Aug 2023 19:23:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535017; x=1694139817; 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=nu15p4NzoIMDD0853qBh0z3WcT+BzXtXp1Q+7rXZXJc=; b=gBMSqB8qCPdmtqqqRjYAma8NCDNIrVEiLMrg4VyZCymxR9Uu1iibRoKomoX9NnMcTN D/4ha1+wh1MHTDKXghPbLtWcEezhyHEIVJ/Zz9PZoUusw3GB/S+w9VMHxoLjHO3xwSN+ HXFV/tASdE2FzAXL0fr9z25MSxL034jSIdZO022hiYiLNXYwdb3CbKcQr7jnUOcTM+Ck ZayDW/5JAzdkSTuMWQ+yip9XuSKXnu1EiGW310pfubngtO5QpMbhyild54NEYOKXuz3Z Os/trERIu49InuI0rzIy2PtCsr8pnAhMAl13jY3fLotxGdB+pj/pEWnnAPN8sGtC2qLw 4TXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535017; x=1694139817; 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=nu15p4NzoIMDD0853qBh0z3WcT+BzXtXp1Q+7rXZXJc=; b=FFLbaTKkD+ADQNwuf+JrjjzmJEVQMI7/rT40R727YpVX60B9GlDVAhYxc/Jui9Z2Ob Rw2tjXCKiygVMrjTDR6Kucrt8rcBkJBaeYA1W8ng0OADzpATmDsxU9C/u+Hzs38uSbQv 5SYiiQu8R0q+fSuUeeeHMoOuIdYMtPq7u8gWA3Q6bqDNIHRjgTEGT3ssqsAMCk1tSWHz e/P5F3BHlYWQ/JR+4uOVxJASXBZxGd1VZuuObmlIkUqbBdFUQMc5eXQ3mMAs/y1pLr7K 92P4BXJxfAzBw9IWtU68rRFsOhVqfPlOkwEFRYcansFzyX6awR1PXjXbLNtQt2tTbjW9 wj3Q== X-Gm-Message-State: AOJu0Yy/cxDSDQVakYxbxP4xDH2eELvhZnBTKUnkKChfirqGo78Xb6A1 YRXHEGeI2r5lpLDb//ZGpGtzNOMw8VDnSbWa6JI= X-Received: by 2002:a05:6808:612:b0:3a7:d857:c588 with SMTP id y18-20020a056808061200b003a7d857c588mr1291720oih.2.1693535017481; Thu, 31 Aug 2023 19:23:37 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 06/33] linux-user/nios2: Remove qemu_host_page_size from init_guest_commpage Date: Thu, 31 Aug 2023 19:23:04 -0700 Message-Id: <20230901022331.115247-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::231; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x231.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use qemu_real_host_page_size. If !reserved_va, use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson --- 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 939c9b4df1..025747a15c 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1355,10 +1355,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); @@ -1367,9 +1371,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 Fri Sep 1 02:23:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719489 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17824lti; Thu, 31 Aug 2023 19:27:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6DHrRviI7xZQMxA2AkqFjWvurdpRdoMQaKFrAObnb1g2DoOF/9lpJcVrzlNXbTT9R16xj X-Received: by 2002:ac8:5986:0:b0:402:d15e:2982 with SMTP id e6-20020ac85986000000b00402d15e2982mr1436319qte.25.1693535271859; Thu, 31 Aug 2023 19:27:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535271; cv=none; d=google.com; s=arc-20160816; b=p78adB1xpN4/0usuUcvYCDVHmfohWabAIc0r9Xhg76LntP2M9370yuMLsCDEG2FwLL 13SZfLvjAMWP3zTEer/F4/yJHkJPq2gqxWNDICZwP1ZktIYvoi+L9W1NL3xSt9TEti1E fCKtEo+eg8Fm5QA2crXzLYGdESwPXB9B6UvIytvP8Yc2jkpHqG7fpyMJ0dKYfwEalqkf sVVU1KRypo8pT6FUbjyP8nAvZrmPOBeefi4/S2cTND9fVyu4paTy28g+DV+z3x1vKuzE INbUryA9v920eehg4JiGgW+ThTR9pKih97hrGqyYzX8HptOPDPwcSEj9Wbn5/YhmFKYy b7rA== 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=NDM65t73LpAV7FxjJeTkMdvecmbGc18VHwUu48Q6+VY=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=ctUrEoXQF4r7H0ytv+sd4Q+3ERlYWtOZJuXAGw64IE2+ys7703t10DZDD49qfF8bEF 1ulDHTIAKSwgRLaA3KPgD3lK6Hffxs7N+HmVVLvjUT80HV+JO3tP7FmlguNcQdgKOWTj DKtpUrhfUWg7Yc/KxQ4InH6u+c3VjqQyPhpfKs2qQ5jAnjsTUzc6ZEMSD3/bY+kyINBo TQ+HIwf7RfMXbPydL7fmXnIEA8qANHq3fouqYyfIWj0gE3EvGBv/L/wQelu11NNfEPlk l1UREiFKKSHBI0yEGqy8Lkohquw9wXUMDKK8he7jp73vUvgrg4UvzB63V4Axpfomgia7 cuVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uo+K7wrC; 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 v14-20020a05622a144e00b0040cebdb7b36si1729143qtx.526.2023.08.31.19.27.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:27:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uo+K7wrC; 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 1qbtp4-0006Vj-Kq; Thu, 31 Aug 2023 22:23:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtp1-0006UN-VH for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:43 -0400 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 1qbtoz-0001Ol-8Z for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:43 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-68c3ec0578bso1242457b3a.2 for ; Thu, 31 Aug 2023 19:23:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535018; x=1694139818; 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=NDM65t73LpAV7FxjJeTkMdvecmbGc18VHwUu48Q6+VY=; b=uo+K7wrCdKhpTjcOIeEC/ZXL5DbD1tokKmA+gfBO85bS9UiqfS9Wn3b883UrzX5jzU 21aq+Hvjh0DNLPE4lGfN3ySZjDVBNHMu3WJfNy5yR4p6SOJdfYXIOHwe8HrmkZdsHsyP /+vlZYGkHbtVFjILiBTnaPWBftCOdmaddOqSHRSDPPMSFJvsfRX09BO8bohUJA81Xd7Q xthNrXJXM6HHSA58/9dToex85+DPOj04YUrt0XpqSwDt5t+//4ESNZpv0tC0/4c3pjcu vX3sNEQE61Jz6ZR53SwubruClD63Tb7kkx7+VlxVCRxOjNStN/h44W8R+Ek55jancgx1 dw+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535018; x=1694139818; 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=NDM65t73LpAV7FxjJeTkMdvecmbGc18VHwUu48Q6+VY=; b=jqjKaFjZxY76kda0yOR6Q8qcsW0VwiSHLcjqvD97zrowRt7vmAz1VrkImufIaTftDR G9nzVdZVF9bBJwdEaJrmPopZTniutUBxI7FLx8mEvjrQDuzenHya0oNdYWpKUdIy1ybc rDQD9527+nFbYP7wgldh0k9jWF2T2Wh8/7cUJJhsWAaad8vCwNGn5MRZc6SZF5u/zicd Z8GHgPCR5lOKHdV9umMR8psPEmWxRDHD1NFR4RbtYRMPxgH0S5O+GJo1aCUTnFVJYU9h 4uNXtzVKlJn5Cm+gnA/h1DydC6qDwKjJCSbrhlrUN3qvEc3zqpDPxHH3o25XLOQnIbNj ZmCw== X-Gm-Message-State: AOJu0Yw3miDhrHtJRbaSbjZD55rkmBwo8pIQuvw0vRPGiLKOH9I1KNdk yktvgeDI+RMkZo8Z+6Fi0AEcyoOX6RUaRNDqdjc= X-Received: by 2002:a05:6a20:1605:b0:14e:b4d5:782d with SMTP id l5-20020a056a20160500b0014eb4d5782dmr1811145pzj.2.1693535018510; Thu, 31 Aug 2023 19:23:38 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 07/33] linux-user/arm: Remove qemu_host_page_size from init_guest_commpage Date: Thu, 31 Aug 2023 19:23:05 -0700 Message-Id: <20230901022331.115247-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::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 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 --- 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 025747a15c..a575e811d0 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -450,6 +450,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; @@ -462,10 +463,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"); @@ -478,12 +481,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 Fri Sep 1 02:23:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719476 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17025lti; Thu, 31 Aug 2023 19:25:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYQ0yAxx9xG6oqCdV3cUtC36sJvXEH5vqpoBTXlXbUwtLm/KGLeISWF9oOqAX485+aFLVJ X-Received: by 2002:a05:620a:2491:b0:76f:e93:eb0 with SMTP id i17-20020a05620a249100b0076f0e930eb0mr1307792qkn.52.1693535123936; Thu, 31 Aug 2023 19:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535123; cv=none; d=google.com; s=arc-20160816; b=L6h4hBj5TWeHhe94Yf96frtuhWo3ulMSLQsWgMFE+TMxo5TYv+f6/GMu8Tgh//ctd8 6HENf0F7rPf00QxpiWS2act0CB1Kt8GZtIVK2NtKxM7JdKk5yH3Ynidip7EOyK7j+j0x Emq5Xh8oCzOz3hIR0ICytg3AkujoPm0UBxXrG+/0OUVcECg0sG0LSM6s3LVN9P3RbIlh coItaeQc3A/FCq5+pxr2uSNW6DZbYzzpAkDtT2hW68X1bhm0TzACHSdWbcULGhdgo2er Bf47cC7FcWwKuyf9brmk23wKJsfBPRIZwcoDoJLjCTbTkO6bH0nuWJHUt247F5rV0oSH tHXw== 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=r4oK6DpGgmRt3Rqz8pdIMkWopOhHonW2cpDcnZxadQo=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=nZeMuJDghb75mZuJIOQse/WEQRCQRzgDPcK0ZRTFn1fd8lXZHrAUdV1Ea085Vqh6OI 7gimLBN2jeG3DVs62FkDOI45Erp7z6vvYsbLe1gqXxyQntGwKQcyVMBVTiVkwsZeJkEV rLxtEVxZW9/1qZiQ84xBczyNk8uI3X0pb3oFWOnnUADJum/Okk25wElPWe8v4zZ1nT72 jPDUS0TPljEf/YGJSFvo+aNo0MhvmIdc+bVMCn2cqhJq9LKgNl9AhLgLbdQ+5QQsmV8T xJ+Qvy4oGqf7NgkZh9rZ4uXzph2MuvA5hRtgdQQmRrJ4LjMES2ykK+wTHCCo0V3Ooy7G 4lsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xZrNlPBU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bi32-20020a05620a31a000b007683f5f874csi1824526qkb.645.2023.08.31.19.25.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:25:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xZrNlPBU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbtp2-0006Un-TA; Thu, 31 Aug 2023 22:23:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtp1-0006UM-Cj for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:43 -0400 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtoy-0001Oy-LH for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:43 -0400 Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3a88ef953adso981664b6e.0 for ; Thu, 31 Aug 2023 19:23:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535019; x=1694139819; 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=r4oK6DpGgmRt3Rqz8pdIMkWopOhHonW2cpDcnZxadQo=; b=xZrNlPBUZZb36OGPapt90/XvRtvUOeD6kuoR0sOZ+ZDuOUCzc7yLDi3YihXDEBrD0p aSOaP9TloRx+AhciqsZ7am/DG41srN7D1Wd4OuPBAq1nCRPIUJurKd1UWi0BNUHvqntO bSj0CMNdRESbvM85ASEWUYvV/S7oSwlHWwdZv2uMr24Xtu/niyTFnvrb7qCh3mxYnvVL 8S9d5SjlOb/DsCdEM5ymFfH+i7WWEcKIf3lNycAobrLpSsvSaJ8SYN1RHMyKZLovIhRI uoTqMUp0Gv2ODh3Xxfm5JdMWDFIJCVcUcjfF885lIH2Im87m9KmqMenTLI3FN1TtjiXN idpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535019; x=1694139819; 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=r4oK6DpGgmRt3Rqz8pdIMkWopOhHonW2cpDcnZxadQo=; b=Bt3Fis2WyKZgl6A2Ce+fulEJk9VzDsOR7TV0K+wZd4d4LnrvrYEDHJ1AWAAx2O0u6d KgzLsuqKgwhmDfiFqBzxH7TwRMUjht6dlTqMBR/j6njOOMhoFrH5+FGKo2UEca1qsOXo r+JwmuVRKExtAGogm5vQMYfUruT21MjWLPqloevo3wc0asW2F3AMzZ+nPhv4DsuiUdoi 0Y4TB4O9NEdnoBqwHTWjgFPCr9xtrAacjusfA+MROupfCm/G0jgYfd9u33UoUnCSyMKh abOmD0e1/55ZMWqpLWKR8qYlgDwMF+/AmJrs149yNTIoy0dfyC2qi6cqh3z5KfbxuMlD EgvA== X-Gm-Message-State: AOJu0YxmrV8sec0YTIoN1gO/JPzTRkxEneEHSRiAtIF6Poi7ytx7iAG7 AluxO5WddxEsxmboLVbAhok4wsJl/hOTutw6PPk= X-Received: by 2002:a05:6808:23d4:b0:3a8:5997:21e3 with SMTP id bq20-20020a05680823d400b003a8599721e3mr1591024oib.33.1693535019304; Thu, 31 Aug 2023 19:23:39 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 08/33] linux-user: Remove qemu_host_page_{size, mask} from mmap.c Date: Thu, 31 Aug 2023 19:23:06 -0700 Message-Id: <20230901022331.115247-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::234; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x234.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 --- 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 9aab48d4a3..fc23192a32 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -121,6 +121,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]; @@ -145,13 +146,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) { @@ -161,7 +162,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 { @@ -174,10 +175,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; } } @@ -189,9 +190,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++; } @@ -226,6 +227,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; @@ -242,7 +244,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. */ @@ -260,12 +262,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; @@ -280,7 +282,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. */ @@ -294,7 +296,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; } @@ -329,17 +331,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); @@ -448,6 +451,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; @@ -493,8 +497,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 @@ -523,8 +527,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) { @@ -551,11 +554,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) { @@ -621,7 +620,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 @@ -650,7 +649,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)) { @@ -659,21 +658,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) */ @@ -739,6 +738,7 @@ fail: static void 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; @@ -748,7 +748,7 @@ static void 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; /* @@ -757,7 +757,7 @@ static void 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); @@ -773,14 +773,14 @@ static void 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 Fri Sep 1 02:23:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719485 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17557lti; Thu, 31 Aug 2023 19:27:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5nbE5dreBPIS6Tqc1wFP4H7DkrRYKtrWwiIoXhHcQCBRW6D2P/7VwLEDVKA1BoWRvCU13 X-Received: by 2002:a05:620a:1925:b0:76c:e6c8:937e with SMTP id bj37-20020a05620a192500b0076ce6c8937emr1484413qkb.61.1693535220462; Thu, 31 Aug 2023 19:27:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535220; cv=none; d=google.com; s=arc-20160816; b=xy1CnP8kPW2aMSPEyxIYN14kdbJqQmtEjcXGU+xRQCwSl9Bj/7XYh0LXxZF+UxFZEi +gWFnYEXYKerZyX9ZwNgd7I8ySSJ7Odzdc+Q7Y9ka00gXUgcmn9KboLOEzeju5tdFvFN /cUHNc0ZbGzglfIeGm9hdUChoIL8la7LJ3TZnedk7hV6bT7klohqsB0VP6ovewnfeQBX 7ZSf1p3Men+M2IyxLybQQU0MuLzyvoYTSyL/GTutJKZ2AhAi6VkFzJw0CTkSSXRWSMFo 3Ivi6YpnudxQ8XQljd5F26kWXzEe0kgyoDVD/bdSKOiA/UP+IXR448F6iKyIkyPs8JEv 2H0A== 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=LVk5X9WdvzLtlHCovbmOH3Icf/xYwVyrtvZHkdMNBJ8=; fh=SfxhhCERWPFe9EfsSkQ0zw+VJgdUi+jLlAbxANM8dQo=; b=m3yk/gPKfCtzzTXaS3VOpFH4+ZYCwutWvd/RGXLjm43vrJ0/NZMAcKSj73UYTIANcr zs4F/ehjk+n1pLD8/dqUmrg2s1N2ODTOoSs/Cb/kSXsiTznI4641ElrgtsAvqAlTohZX QoRuNRDuGjECxCtVp7qw+NeboJ7MFN/BrToEswkN38Us2m1HtXWgcnq+h3KfEEu2Rwxq 9MB+/0ZLyYjxt7g776thDHdJgQticnlHAsmG0b8g+UOAJ8uHiFOmqEBePLqPKoa8sREB JVZ4SBeQCq/WYQXxGg8XI/4uCKmBwpjayviqcN23weOcIkX9owQ7L+ilY/0FH6EZQ7+j V6Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DJHlhrzj; 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 y17-20020a05620a44d100b00767ee53f0absi1864952qkp.340.2023.08.31.19.27.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:27:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DJHlhrzj; 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 1qbtp4-0006Vc-1G; Thu, 31 Aug 2023 22:23:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtp1-0006UU-N2 for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:43 -0400 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 1qbtoz-0001PA-I4 for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:43 -0400 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-56b2e689828so1155217a12.1 for ; Thu, 31 Aug 2023 19:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535020; x=1694139820; 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=LVk5X9WdvzLtlHCovbmOH3Icf/xYwVyrtvZHkdMNBJ8=; b=DJHlhrzjtGxAqF51HsLiOjtbRj2CgTD8jpjSVGCKJKwMQDsg4465a4y+CxEKmRcUhV apV09VIch6h6yf+p9Qps6DbqXhpsOCv+YJ/7XLbdCxHB1ENyuIx7KamkJ1lGK7UWKwZw U0gIkrEblSGZzD/1+MqtFK2OQv7bHQsLVxDgTPhu5cAucJXDBMQT2e35MidrsB44Bmdb dlXSSBEnekFUwD88AJFCsKcUNsjPY58VL5/Is6qoBhK3YpUqLO3WRqf4eTe+FT3CmUA+ 1kAdhLzrxe5w+0Lfo/hucSABUwLQtscjVN1Aa/BQFBtUaaExHALcYkAcqCrb3YHVdgfx YxQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535020; x=1694139820; 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=LVk5X9WdvzLtlHCovbmOH3Icf/xYwVyrtvZHkdMNBJ8=; b=DvOVWR8J/uVdOCx1dze8kXqAp5WQoFkXMZF9IjWA98lo4bEBVE1BofjTerg2vUv+JZ ixegfwyogm0Rho60JXesInQTIhQeQF0I0WsPk4YQMM8l/rCoKG4XGaz5G9gH7qQh5L/X J4mH0Zu7kKcQZmoWFjOrXtmBIMQorS3d6m0+TqYFvStjvUjDs1aQPaO7gyLlj5CXgFvm USv3vgLQyjNmphxeYQQ1/sSEjRAD3N4fUkVAed8Sm/ih39c0Uwt1qFJkVtk2jcbPUfEu /pHAgp2ATY9tb5KO42hhy7LZ9pHQ8SBpOExZMtffxwnnTUibX8UsFUILGN9TmVTORvUX XT7g== X-Gm-Message-State: AOJu0Yylr0HTA1IdqJfYuckqvTrFqsmJR/J0pmXGUGwDnXxw65pH8dXF E+RyCsyLbl1kimKVit5cceIMV2rGcvf3rJ4pQQQ= X-Received: by 2002:a05:6300:8084:b0:14d:8624:b144 with SMTP id ap4-20020a056300808400b0014d8624b144mr1449067pzc.61.1693535020200; Thu, 31 Aug 2023 19:23:40 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= Subject: [PATCH v2 09/33] linux-user: Remove REAL_HOST_PAGE_ALIGN from mmap.c Date: Thu, 31 Aug 2023 19:23:07 -0700 Message-Id: <20230901022331.115247-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::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 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 --- 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 fc23192a32..48a6ef0af9 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -541,7 +541,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 Fri Sep 1 02:23:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719488 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17773lti; Thu, 31 Aug 2023 19:27:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFoBJp+zyK7VQYL9MU+I9tOTWdhWMGnprxDPAwmM/ta/nQqt0qRCiV89+pwFRPL8k8MZ0Pb X-Received: by 2002:a05:622a:110d:b0:411:7212:bd66 with SMTP id e13-20020a05622a110d00b004117212bd66mr1921951qty.66.1693535263934; Thu, 31 Aug 2023 19:27:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535263; cv=none; d=google.com; s=arc-20160816; b=bHXP9HoQRWFuJoMEFVGcM0Z7dIekXq9ik3FXBe0gqJd2JIAJSfDDxHnWCibhzniUrt iVaPeP6DrURn1JZy38+mq2uth3oXr6hc4MgckLsht1ATi/qjqMQiNbbraSd3HziqHCz3 4DQcefSmGsv96+10q0pGR2IB+/+lnWon2zNrLo03sGOYXco/0jjF131ERFNGXgYgf4x4 Ty59GjNFsgtVvsY/h3rpb7/6H5cyi4sKZew5SAHEBenh76Ejo9XojDa7jyKeju0YsqH9 952uIHrJw4eAkNjoSZk6PBiP5yY7jB1Hq7sNoJuVrggrjCaaONAXp2gUFpCWbg5uoVg/ w5Ug== 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=zm6LGbzRYY77HgezAnXq5Cmr5DPYLmRbQvieaAAbplU=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=lmQbks7AB0jbuz+krtORUp2k2FAToovphkeCw2givHvlTIEt8mASvZPCIpZGyEk79t czRQz83Nl2xE5RFLShY9yjz12Jow3W+GVIShF9Kn+TyDUjU4Rb7Bnnh2jJ3YGKuo5/WD Q677AUpz/PcWUI3eq+5iUUJ1NnCbm6pgvThuEhxv3BV1vB2ID1yC9a6GKlhIW+WsNhb4 FrhxSARlmimhPAZ47r9GFInZC+QUE+fDWX+XB0Tr0KwL4JTi/UjwtgGtY7nF9jzNs+ua Jtrz3sga7fN+HD3EaCWuv6p8y5FVfdJBohyvK8I6xXEXU3+Z1hHuPA6w/IyI3cq9prvy QYIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vFtmh3Ay; 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 g3-20020ac87d03000000b004108cbf61d2si1702052qtb.251.2023.08.31.19.27.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:27:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vFtmh3Ay; 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 1qbtp4-0006Vn-Ok; Thu, 31 Aug 2023 22:23:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtp3-0006Ut-DM for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:45 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtp0-0001PL-E9 for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:45 -0400 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5657a28f920so1127208a12.3 for ; Thu, 31 Aug 2023 19:23:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535021; x=1694139821; 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=zm6LGbzRYY77HgezAnXq5Cmr5DPYLmRbQvieaAAbplU=; b=vFtmh3Ayk5pYrrixU+DuIu2Sij3d+4WQmsDPJrLJVEigf4qh6NqnL3IXkmb98efJbp PKIeqORbgfHt8WdhjX5qhEBY4gAPqQIuCLVV/V5MUrXfEPhbp+QV3i8hQ623T8icjWr4 ZpizZwlLbdSls702Anq7FQKGKzj6WnpiChVOXKJI4Ji3XdSi3m10Gr6nzOYq5/uHprq8 hyFTaetuNuB0sGa5O4S15mv3gznOulqRI7RvhaGtir/xHIvP524e0CZvT4jJSdLaavie jBzkWKCRzRMOfAAoHrwmU8fqMIAm66pUQxtDLA4jv9uEd4b0Cu0W/vngwh4zHJLqB8DT F20w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535021; x=1694139821; 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=zm6LGbzRYY77HgezAnXq5Cmr5DPYLmRbQvieaAAbplU=; b=ZHO94/gSWdMRfkN0fT/myIm97nPFNW+Pl+hu1xVbNNmrO0BxnDM9nc/HqDFlJECk1l KnRSdbnAeqS91BwJlsSnGgn3+Quy3lcAopN7HlwoKW3v4ZgcwoG4CoT2Os+IZ8tlf2hZ ZTW3hZ1rz8iLEvj2TpICnbeNKyjrNTSPffTxtUtWOWi0nDjnrPhZAv81QC1wNAn2XEfI KbgxBBlwVogUti3lupkK5P5lM3Dxutdp5RNWz7pZFnClAMvZjt8i34BktNJGd5DJx7Zs 8yfNA0lGzkwbcmxqUkdarTY08JL48OOSn6YBzgAkxJXpqH4bMyszgGgJJHA7mvp8O1xL om1Q== X-Gm-Message-State: AOJu0YyBUmh+Bmd+XB4ZveixBaIFCV6SKurKRiemYovIg01TXmbEsH+5 +bTTdFk6eJZbs/RqZl1M9wB4H9U2XE75bl/HLxo= X-Received: by 2002:a05:6a20:7f97:b0:140:a25:1c1d with SMTP id d23-20020a056a207f9700b001400a251c1dmr1979700pzj.51.1693535020905; Thu, 31 Aug 2023 19:23:40 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 10/33] linux-user: Remove HOST_PAGE_ALIGN from mmap.c Date: Thu, 31 Aug 2023 19:23:08 -0700 Message-Id: <20230901022331.115247-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 --- 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 48a6ef0af9..35f270ec2e 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -147,7 +147,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(); @@ -345,8 +345,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); @@ -506,7 +505,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; @@ -551,7 +550,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. */ @@ -581,7 +580,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 @@ -749,7 +748,7 @@ static void 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 Fri Sep 1 02:23:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719486 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17635lti; Thu, 31 Aug 2023 19:27:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMgrbcs203p8+L1a9+wVR5B0KSIsvpEA5APBLTwA9TD7TE03TGdmoGeCVxLlpzDR2KMJsG X-Received: by 2002:ac8:5804:0:b0:410:31c4:f460 with SMTP id g4-20020ac85804000000b0041031c4f460mr1466945qtg.1.1693535232247; Thu, 31 Aug 2023 19:27:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535232; cv=none; d=google.com; s=arc-20160816; b=YnAr/j0VlPcDjOIxGcbZRzc+xYSzdrNkd2t99vqa8Lrt7VtMiokWeFAk6xgbq7BoHz S+r4pV109/yLw1BVVgF9kd6SJ2FLNEz+uT36qCbppcEgC5iwS1rte6s2CRfVsKcneViv WC9KVPvYEp6EWkrwKxh3JOu/ewySAn9HbZeJ+2lhPVyLDtuA3maM49mr4n8QMCFSgoDz h0JvEryq8dhZIb+DYFiO3xfLZ+muecbq5LnBcD5OWzN7ub+LFbg51Lz9j3yeMJWh8xwc dBCgxdvP+YYERMCLgGtSxV7Wepx4dCNEwfq5pNWEuqg0R2SZoz3yB08Ho49JMjrOpJQR lh+w== 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=aNsGM1lrXvwjZfK8fzxAwlxZ3vZk+R9BD/kfTxJ1kzo=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=I8HLxnbC8xKKjfo25x1cDqg7JuZepjIEWvnh5DKsRyBb7cwxB/wMEi+tsn+vZS9A/j pXnIcUO+hM8gAgWjlIh9vbNIKeTUi6xf/0tNIIgZ053dFvgc6uI7RLa8l0+4+xMNMtKD d9myPqEyzsN89bI6Zfc/SMIepE+cY7de7yxG/aVTMDrHjuaaVL2jo69RoBPN/9k0q1cR XQrOAnWaFriy1xwsVB9qnrgWE0d9sRbY6c/n7fhLpiKIIMYiwvLLzb7o0aWHW0lcDiB7 QSRoL3yKX13QyNAfaZ2FVlIX14i18TtqRsB/Nw5lxlwS3iOgWF718aTHS25rwgu8wzlt LP4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jhxuPfKL; 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 b12-20020ac85bcc000000b0040fcd2978cesi1731534qtb.450.2023.08.31.19.27.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:27:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jhxuPfKL; 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 1qbtp4-0006Ve-5d; Thu, 31 Aug 2023 22:23:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtp3-0006VA-I3 for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:45 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtp0-0001PR-Sa for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:45 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-68a440a8a20so1226061b3a.3 for ; Thu, 31 Aug 2023 19:23:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535021; x=1694139821; 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=aNsGM1lrXvwjZfK8fzxAwlxZ3vZk+R9BD/kfTxJ1kzo=; b=jhxuPfKLM0bctrTZI0TS5Ky/ZcR+M0egaf74m1Lp/YmxfSDkHXlBFyV9MWk9PQAU5x ojEJuBYPDrojzsV7yHCp4fpj2C3698ZHmzd2QFUaYYYtc8FFYBOzRQKBDtO8Qze4jJrv u23sVjemRKXorXMiF/dqFFT0zA/CuxzZhIGqNj+qw2vtXaHkCdq42he8fAsHQAysUncV 6ns2DDSfth4QrCe2LdYM3JEnBTpszKRl5f2sLM2+cwTGF+A/7gSJkVohQUp2+m7qf0Uc 0hQH1sH88cFS0ZKOee8C+jeUOmAZmBQx+Z9/MxMozvNL4kzA38a7Y1qtFNFlXFQw2Zqn LhCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535021; x=1694139821; 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=aNsGM1lrXvwjZfK8fzxAwlxZ3vZk+R9BD/kfTxJ1kzo=; b=N7J2mfaCn2oiwrkSZANCwou6xJMU/kaSy1XV0bRFuBQMNwSUJaVdGtnlpH7MsktpcH 6NQjjF9oysPPVkx3w3bspNEyDDSvh7brjHztIBg2TC8ug07IXgNHTflqQ7daRzz7U/Du bqbD2PDaGfPWyjR/UFTqHCxX6Fl4GzUyRasVBFxP6s8D6X5qyJCcAzmSYeb7Z3Pj9vlo kNVqZNVMRsRUvVIDag/6hnqvkk4qpsuiinUcKnJe41Y1YMGl0Xbz+Qs94oItco7bVZ8A 0StLniJytEZ7PU8q21on9boHSQcQAsqahrz8ffSrLOEQZ2RQ9/CdlKpoCWWHE+tJXis0 +fuA== X-Gm-Message-State: AOJu0YxzuEQleXGUDF3zXuycPN8MhPKQ1gX+hrfxb9UDpQF2I6guPw4d +N4NaPFi/9MPMsskAsJwi1/G7tLYFdLl/V/evGY= X-Received: by 2002:a05:6a20:1444:b0:140:61f8:53f3 with SMTP id a4-20020a056a20144400b0014061f853f3mr1942189pzi.21.1693535021632; Thu, 31 Aug 2023 19:23:41 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 11/33] migration: Remove qemu_host_page_size Date: Thu, 31 Aug 2023 19:23:09 -0700 Message-Id: <20230901022331.115247-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 --- migration/ram.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 9040d66e61..1cabf935f2 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3033,7 +3033,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; @@ -3048,6 +3048,12 @@ static int ram_save_setup(QEMUFile *f, void *opaque) } (*rsp)->pss[RAM_CHANNEL_PRECOPY].pss_channel = f; + /* + * ??? Mirrors the previous use of qemu_host_page_size below, + * 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); @@ -3056,8 +3062,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()) { @@ -3881,12 +3887,20 @@ static int ram_load_precopy(QEMUFile *f) { MigrationIncomingState *mis = migration_incoming_get_current(); int flags = 0, ret = 0, invalid_flags = 0, len = 0, i = 0; + int max_hg_page_size; + /* ADVISE is earlier, it shows the source has the postcopy capability on */ bool postcopy_advised = migration_incoming_postcopy_advised(); if (!migrate_compress()) { invalid_flags |= RAM_SAVE_FLAG_COMPRESS_PAGE; } + /* + * ??? Mirrors the previous use of qemu_host_page_size below, + * but is this really what was intended for the migration? + */ + max_hg_page_size = MAX(qemu_real_host_page_size(), TARGET_PAGE_SIZE); + while (!ret && !(flags & RAM_SAVE_FLAG_EOS)) { ram_addr_t addr, total_ram_bytes; void *host = NULL, *host_bak = NULL; @@ -3987,7 +4001,7 @@ static int ram_load_precopy(QEMUFile *f) } /* 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 Fri Sep 1 02:23:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719465 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp16599lti; Thu, 31 Aug 2023 19:24:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE9SrSmKQOJceSyWZ2sTTucbVDkUc9A/XNA063MHVgJMOLgCutHMor0B24ZkfYRA1H68Gen X-Received: by 2002:a05:620a:4106:b0:767:f178:b571 with SMTP id j6-20020a05620a410600b00767f178b571mr5488797qko.10.1693535052023; Thu, 31 Aug 2023 19:24:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535052; cv=none; d=google.com; s=arc-20160816; b=YepBtMpxG9IeMjzjhocwfVGbawDio1K9gKjEzp952CVK2e4MBacKHq8knzhTzET+33 fkEht8hBAYbTfx7Uuc/YZ7juvCnt6X46dpKKNFvC0jy+Lh64BCd6zqN0xmzXVRelpA7e L8SFipGWXfZyMiWsS4G7XGLmKtPH8GOwRtbMnlQkXLaQDTHV2t0MfxmMSlPBaL5Bhvkf ulRDmacVnvhk6ZHbH1z/3IgDqBIBlaaudn7qcYFY49pexlptis4wRQ8vMNKgMv4rITSs 7CbFSNdyNyIjxhYQYzlh6JfjKa+F1DL/DiweY1UK2G//6vRSJcRfBf0UtsGTQOy6EDDX s6wQ== 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=jBDFYDN4txkYXCl4MK4JvDX5trolAszB5+TZawsyMV0=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=X3sh9Zk8EEhxJQv44PoIxIYXLta8skuXdkm+Gagk57YcAeYctr+w4eXVZCetWomVIs HxsDYqRuzvpS//0XFbE0iqAj4u1/jLj8tOyUBHioFdHoLKd9TTe/yC8zh8ziUdgo+M4y zTjbLA6L9DiDuLMFc60ctRSSbg4+hifHWXaT7a1LNlejWcW1IJXFjivDDSKjA9EawEdA 9hbXVDFtr5QPJLrdE9Ov3DiH8fC6xXERb9009RJ0bXGoB3k8HqORgkli4hkRYAxbrEBp M3YxTmj2cZP6gQTuof2vbKTgGJxMG13UwA0prkWJT4sndeRI2dgOJaj3vpJDnhKPhK7K 6ctA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cChTyy1Z; 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 p19-20020a05622a13d300b0040ff1e16fd2si1738929qtk.672.2023.08.31.19.24.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:24:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cChTyy1Z; 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 1qbtpA-0006ZS-0o; Thu, 31 Aug 2023 22:23:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtp7-0006Xj-2U for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:49 -0400 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 1qbtp1-0001Pc-R1 for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:48 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-68730bafa6bso1786130b3a.1 for ; Thu, 31 Aug 2023 19:23:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535022; x=1694139822; 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=jBDFYDN4txkYXCl4MK4JvDX5trolAszB5+TZawsyMV0=; b=cChTyy1ZzMTqIxYW36kM2ctmYcGNgrUMgrBzielzvrybjpy9XA5pWQOk4vLXE9XF7m aUI68YPcvgddjUEA+dXAq1Komp4Ya+HWfbdxnw4pIwogl4BabJkmkyOSOppgZjw7xLGO 2Nr//IGZGQx8qgtH69WWe0Shp7ZomOVOTbfo9E0H/a92YV4nRc7ekQIGd4TACAWXvIEI n4Z+zqsaNvGffVNupyJycTDGpsLumZgPxui7N97eBk7nUqu99MW+RM25AJYWEI01orRv KYR0OAQkileief2hUDKcI6zDERev+ne7Cmii8ZzHkZFdAuJkwz6tw7Nm1cyjTyxs+CV0 CtmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535022; x=1694139822; 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=jBDFYDN4txkYXCl4MK4JvDX5trolAszB5+TZawsyMV0=; b=bGA/GadQI0faOysTm4ScWwhWST8TFFHRjaZqqJ44oZ9/ZhkmY5numbYMrGRDv/b1aR SLpNMxEm1LonAzugX5SVar1wyu4tMiJcZ/uEfupnp8UKvSmSQaHdhpeNYMUTCMgJ0mcy NbyMCwcu9hDLoqI9TrMmL8fsJbnYY8sm6ehi8VpXg4Q8GLiZ7ghnO6zd3dNfKgzvqQMG NpcNS4d7qmYPDmjaVvEioUa7rBlVobbf8ZA7f55TUsoodctrGB8m4uTRrgxIrKxp2W41 SoNpW0ACzY6obkZF4UP9KX/JlKbMjQMM9qgWPFVPfwzIn/Xm3l5S6Wi8XwflswpSRzx2 pxNg== X-Gm-Message-State: AOJu0Ywxp48cMrT9P6lzEtM4/QOHvjMVu3MNnUKEofMEdWGbpjsIZ4Uu uqFrpt7zYMSuAw9eL9W0iztMNLWiQi8iN3palAI= X-Received: by 2002:a05:6a20:7b03:b0:13f:c159:63ec with SMTP id s3-20020a056a207b0300b0013fc15963ecmr1183911pzh.24.1693535022590; Thu, 31 Aug 2023 19:23:42 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 12/33] hw/tpm: Remove HOST_PAGE_ALIGN from tpm_ppi_init Date: Thu, 31 Aug 2023 19:23:10 -0700 Message-Id: <20230901022331.115247-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::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, T_SPF_TEMPERROR=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 --- 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 Fri Sep 1 02:23:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719496 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp18083lti; Thu, 31 Aug 2023 19:28:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVPKpFFO1rFNd1sGTcHYBCn2kTwLReV3zU42Lhj/5s7izUngS/B64QsX2ygFCLa/f6YeXj X-Received: by 2002:a05:622a:10e:b0:410:aab6:7f60 with SMTP id u14-20020a05622a010e00b00410aab67f60mr5304065qtw.18.1693535312730; Thu, 31 Aug 2023 19:28:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535312; cv=none; d=google.com; s=arc-20160816; b=F011yU4CwqgDibPD63cLFGt8y5xfhGmC5Gj5+5p950QvcGbO733nfSMCFSuVW4X4Jc Bq6JzlQU3iHmoxeY0vdMiEUKpuxgJrOSWMnS/NARFkPfapt4hFtEOBnRu2y8rrWtS/WU hQQ9yew3Yx2hh5jP3qhT/rYj4cdJV4naiNodjDhq3IClekTJIopVqcr/onC2QF2ujxei JNGaS5ji0Lzz9hbwVm6cnf6ipTD7ZhCNytqiTImK1j8V9eYRne36aUz0LVrXl0StD/Bm kcFCC027gjX+7FP8iGdanYGbnfxAKGqOjJqY4ssr6t5a+U6yWNe8Jo3c7CpeqK/5o3SF 8ldQ== 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=RG0I5fdtJkgseX4CxGvr61fKZ2D6UQ2yfGBN0aVfn4c=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=aYrNRKT+KRUAZIATTHz1HEokPdEiXrIBwJn2Q/mGWQ3Z06LoQU/UYm+7Ct2pt09rwz MGN73VBwmTQdrs1afHzt2dDT/JUfAi2o644JxPTMRGoHoiu4AAKWAJ+8lBAO18Q9PvQ3 0lYp6jmy5NU68SYUfYHnV3GYTbhZyxjhUUuodw/PovQb6AyddXz3JkHZPT0IejNSFXNh rBXWDQTJyuv3VXG5rlgeOqefuzw/hI5UUSGcvk40MEMGNZerlIb18KsDAEeDm6FTuI5y dxUciZ03bfETfeW6IUczl0RULryprDB298EoeKweCtEiqzFHKjpo8pnyquDneCE76nZP j4WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OaqZ7Rvd; 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 c17-20020a05622a059100b0040c34202141si1713622qtb.504.2023.08.31.19.28.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:28:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OaqZ7Rvd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbtp6-0006X5-Bw; Thu, 31 Aug 2023 22:23:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtp4-0006W6-V3 for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:46 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtp2-0001Q1-Ov for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:46 -0400 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5657add1073so949916a12.0 for ; Thu, 31 Aug 2023 19:23:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535023; x=1694139823; 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=RG0I5fdtJkgseX4CxGvr61fKZ2D6UQ2yfGBN0aVfn4c=; b=OaqZ7RvdwfUgVnBPAXgX2gbRR5X20w33zuXsfwfhRYKEnf9q+OMFWmuGWs3M45swX0 TxC7P8woxBI2S73dvbSJAtkiak6yyhUj08CDFFFGTJ2jgrzE/5jrmSeGfla5O7jjSfAt TraQbnqswZTWWPOtzC4m+IK0RwOaFU3BKWptYwYrtNIzI2iGlw9cSQ1jsSD+ynpwbVfd wGN5VaLs48SW/2TlvfTyl0DTJhZiVA0a1nHN76bahaPQtiru9fARjabi3Jjyf8rfcv4h eScrKewSSlf//kevFCdqr5XuhpzYxV0huYyQH4gXYp2S5Z0xruHbWHkPWsgddJ2XBVSi iGPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535023; x=1694139823; 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=RG0I5fdtJkgseX4CxGvr61fKZ2D6UQ2yfGBN0aVfn4c=; b=gVa0j75EOcBkpVe8L4+HJ8hxKTGw+SuEZlKZKaIL57Bb6J+IMJi0FPQbD3TUmyKIVC /GlFaKp8yDZIkK1aBn5iorRIIaEfYXIDxa9xuvfo50HNFQttZH0+3cK3uoPjC3OU1Z0I 5bZYOtXLRKpcrlR2B4hnDCovfVRcC6zp66G7jXr2osCWh0JuvpPFlqvAmUwo3iujk+C1 I2gafRq1Mx7k7AoWUMtJLu/vnhs2gq3xEnF3fWajvEmXV74SvfYZuzEMtzg7EyjFrXwq rLTTRAPnkDq7gMY6G+keJtHLY1GODUXi2/aGGYj/2BEDOp4lVxK3jRI1heE5kna++n4A FY7Q== X-Gm-Message-State: AOJu0Yz1ex+7MO6LsymFcQ6fG0XoQOdJ6/BAthTCoTegsd06BC86W2rQ nYbvQG28R4/mvVDOiLk9dte6Ddwc05o1zzhSs3c= X-Received: by 2002:a05:6a20:1451:b0:13f:de94:fb97 with SMTP id a17-20020a056a20145100b0013fde94fb97mr1798744pzi.27.1693535023497; Thu, 31 Aug 2023 19:23:43 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 13/33] softmmu/physmem: Remove qemu_host_page_size Date: Thu, 31 Aug 2023 19:23:11 -0700 Message-Id: <20230901022331.115247-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 --- softmmu/physmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 18277ddd67..6f963ea127 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -3472,7 +3472,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 Fri Sep 1 02:23:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719494 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp18020lti; Thu, 31 Aug 2023 19:28:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErdd8H7fzHzkhp6BA8g+eKF+4bsODh9jXjPrLw/Q2BizeNv+Z9o19V322PLG2CgZ085CnC X-Received: by 2002:a05:620a:4414:b0:76c:ae1f:201e with SMTP id v20-20020a05620a441400b0076cae1f201emr6325534qkp.27.1693535301587; Thu, 31 Aug 2023 19:28:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535301; cv=none; d=google.com; s=arc-20160816; b=ntkP3GswtIAUJjQuRFeK92HjC2y5qg4rHTZ2myE4D6bwGUYt4+jdnLjGezZxsN9hJG 3ffHUxLWh5BMRHJ7q2loKt0D0VZQGfB4ZMfkh5KzRehsJoQDkVYdSdTEqG10bEgJ9XME B25IKHQk7GzKAespXdo62C3qrQ26Pu0me9zy4qykvyDMH/jQvmGVtlE8eJtW14I6i21B O5/6slsBGFIjYq3JGADHRBcXmjAAV6YYreJkUH7rt1+iU6j9L3435xAycEcaG9JN6GKf 88wsh6zbHBSbX+XyWtAX1uk9gnaBsekgLKMWkplSxWVSFx669RPd4+n5v8GnQLm9qatP 7nIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oX0Wvey1e2J0VCCaIBZPR7REasOlAnSls/c5wuVfncQ=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=0iwKU30tXBqL08gKFYCOhcI7lkz5kPSEVdge4NIRlHEAe64BPHkrmOLnMhmwm1Si+X tC7/gUaX7cSwpu0wHjFL8jeOWrcka8at5LUlRnbyZxSRcMgYLguSVN98FQPjmlIytvIP XJXMz8OPUMMDfkHvrMPn6p5WsOf6h1bq83KOcn4tGmFYJD929Ic2GR1X7fXIuNrifgF7 9aEklXakoS99uAlcJHFZucfyI7CYAs82iyUXcr1D+sTZZFs0naVRBaEdMFeaEhdO49PG rGkm/mC1DTozuj7UPwwNv46gcs2WKEwlw+bMwOupIdMCWjeuV9WnUs0CIZ95XcDNpWkz z5Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KW+ZGb3t; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fi16-20020a0562141a5000b006505e1ecb0fsi1759301qvb.212.2023.08.31.19.28.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:28:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KW+ZGb3t; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbtp6-0006Xg-Te; Thu, 31 Aug 2023 22:23:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtp5-0006Ww-Le for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:47 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtp3-0001Q8-EE for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:47 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-68730bafa6bso1786144b3a.1 for ; Thu, 31 Aug 2023 19:23:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535024; x=1694139824; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oX0Wvey1e2J0VCCaIBZPR7REasOlAnSls/c5wuVfncQ=; b=KW+ZGb3tufrc/+PV17+VgExsYCcQKh5d6nmfb3amL6MKyYSKlOqndrXHsMm7K3lQ4j X8qc79dpPc36U0HHFkj9xvyRrA1CbWCzo2XovOgsb4q3+AyOn41ySSJIjoEeYFtnN9cy Psai99+kh2jRvdorZFerM8llchvplW/3K1d7X5Tk98Di+j1ypv58vxNpOI2aElE0v/+x alZu8es1PnRLiW47ngZlkvxWnukOn0j5aNQ1vYuHW2esN+FrW45beMZo69SGqwjByJRx oHRMUAkhN8foTr7N/aScr7FUgzw7we1oHZXw+5aZQCfrT4DFduq0ypiH6pJnBJdJOgYL DiKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535024; x=1694139824; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oX0Wvey1e2J0VCCaIBZPR7REasOlAnSls/c5wuVfncQ=; b=HQ9YSz0aYoIpP/n7rrIZFyX68dXKZfrFNNvZWxZq8q88x3DPqzYTkCyrn0UCswmC0K I89DRoqTceDn8gOhInzlekkAyTsooP15SvB7O+fJHwWz24pZIAYPvejHFUMmuJ33gTd3 w44AmYvJs8geCKYSbjhw6dC+i45Nnei0NJT1NvTDIZReRWYvl9eF6FWWIq8lq1VxyFsX ozF0bvSoanlfDCEIjmiAi0jgV7J2fVDN0g1sp4MIR7602M2IBtiWLaAMwV367pgLFa5d y17TNnw9lByMjORa2NN5r5OSpIom8W5emqXi06KntnH8hk5E/TO2Lys1+NWuL99UylbS 4UYg== X-Gm-Message-State: AOJu0YzBb15o/JwteZ6FaTjthOmX4sIsjAbNc6rczhP4s29fO390ymGR SQyv10YSqgfAzJOdyjZChJw7qrKMeXhaiVrqZqg= X-Received: by 2002:a05:6a00:27ab:b0:68b:fc76:7dea with SMTP id bd43-20020a056a0027ab00b0068bfc767deamr1541860pfb.12.1693535024189; Thu, 31 Aug 2023 19:23:44 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 14/33] softmmu/physmem: Remove HOST_PAGE_ALIGN Date: Thu, 31 Aug 2023 19:23:12 -0700 Message-Id: <20230901022331.115247-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Align allocation sizes to the maximum of host and target page sizes. Signed-off-by: Richard Henderson --- softmmu/physmem.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 6f963ea127..04d8423b68 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -1662,7 +1662,8 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp) assert(block); - newsize = HOST_PAGE_ALIGN(newsize); + newsize = TARGET_PAGE_ALIGN(newsize); + newsize = REAL_HOST_PAGE_ALIGN(newsize); if (block->used_length == newsize) { /* @@ -1897,7 +1898,9 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr, return NULL; } - size = HOST_PAGE_ALIGN(size); + size = TARGET_PAGE_ALIGN(size); + size = REAL_HOST_PAGE_ALIGN(size); + file_size = get_file_size(fd); if (file_size > offset && file_size < (offset + size)) { error_setg(errp, "backing store size 0x%" PRIx64 @@ -1975,13 +1978,17 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size, { RAMBlock *new_block; Error *local_err = NULL; + int align; assert((ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC | RAM_NORESERVE)) == 0); assert(!host ^ (ram_flags & RAM_PREALLOC)); - size = HOST_PAGE_ALIGN(size); - max_size = HOST_PAGE_ALIGN(max_size); + align = qemu_real_host_page_size(); + align = MAX(align, TARGET_PAGE_SIZE); + size = ROUND_UP(size, align); + max_size = ROUND_UP(max_size, align); + new_block = g_malloc0(sizeof(*new_block)); new_block->mr = mr; new_block->resized = resized; From patchwork Fri Sep 1 02:23:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719495 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp18022lti; Thu, 31 Aug 2023 19:28:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH5rUv13y5ON+NmgW/iYuGYxaA2RLlOlu5lyQnyeDnyt0ZZ/lT4ynNzHpv7LeCidqeNKqKS X-Received: by 2002:a05:622a:110d:b0:411:7212:bd66 with SMTP id e13-20020a05622a110d00b004117212bd66mr1923606qty.66.1693535301560; Thu, 31 Aug 2023 19:28:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535301; cv=none; d=google.com; s=arc-20160816; b=FTmrN6zJOHwHnGGlDTKs67AIgXI1OXwpXEd5LjG4RelXAd2tUbtG6fZN628U8rc6Ag 6BSvB1bAid0jX49sbseRSR/JCMFw175q+y0pwLlZ+P2GN4xi8GrZfUEQA3HtRwwJySG1 pnwdBa8EyksWmjqpIySQoLf5nQ9/ulL62sToRCDwyRaHtUlKGkKjbLo7O3quqotcNok7 vHLJb/r0S8KXtTePAyVBwyDDIEDlTPX+0yLqsx6nqvPZrB1mt61YHeYOFbtJZYlH1PyW bcfqRqFXUc4ZEHidrB62WRpsyn61ImAXw6994GVZSTxEMAThD5tgFKm1kzKxxjIjqTPQ EGkg== 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=LMSfIZM5KDQOW8rzGrPmwonqS4UNbZW6sqmCOtQy3AM=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=in0rj2uZ9ha8B2vhiM6v60ckM3o6/hyx2aVOq4t1sbtK2KPQQ0I044mnpLkYaMUSxN VsE3q/2gXVtGYJ6OOQWn0aeqRjvV53aN5KBGwA1eGECBjYWnDyRI4j38Y5mQis1s8Gs/ oR7kP+B4oI06W12hAaT0/GN+XEVCfyy1Y7gyX/vmCsEuLnJFG1kmfg7x9AGp+rTSbjzH r7SwL2BDGJpi9rTuIKP7t2eyKilr6MBhuOV1xpSUYp2zl8JzNLI9L/qrROvlru9JvO1G gFphZG4Vn+prRQIh6RBIjwuOYXzpTNd8Fdjl/A7dmJJMhCIIwyCPabN1JbqPBt2EWGsy 1VYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ewC4cww5; 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 p9-20020a0ce189000000b0062103dad3d3si1654692qvl.538.2023.08.31.19.28.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:28:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ewC4cww5; 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 1qbtp7-0006Y5-OR; Thu, 31 Aug 2023 22:23:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtp6-0006X6-Fd for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:48 -0400 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 1qbtp4-0001QL-9i for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:48 -0400 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-56963f2e48eso1134650a12.1 for ; Thu, 31 Aug 2023 19:23:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535025; x=1694139825; 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=LMSfIZM5KDQOW8rzGrPmwonqS4UNbZW6sqmCOtQy3AM=; b=ewC4cww5K2LjJSWEuc2hv5DOMcp3VBNVXgrbIc4na5J650IR9g0Y2IlR/MeYRzUbXJ j7vqOJ3a+vHQtj9ynnPnKsKuaavu302aAg+IMaUW9SHGaBsDwiwMI9+zVr6HkbNou/V0 LqWSEvfIO5PVm+siFPNK7prUxvfrmEAfhsNEFS1ER2eNVN5ma9C7syCZRgTF+T4/YhnW Xne86JvU4APCYSIrkU1qR0G4tfEiasuaBST87dE7pk2oogKzCQ5xM+IiYbPHxH8A+w7w JAJKQBxp7yrv3UjlmETyBXnfxe6dT5iw8Am+BovOXCwOpzurkNf0vkR1QMriOtEeMLCQ Lo8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535025; x=1694139825; 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=LMSfIZM5KDQOW8rzGrPmwonqS4UNbZW6sqmCOtQy3AM=; b=CGEHfzYYyaZiZjRQV+HWfThz8gKK9hlcMX1eVSq6GyhoKZpkkpqBclLwM2JLzI++iw VQQOkgXmPOgO9vWsUdOLsTjaJUohqqVOR+1y36x8rxusujHWo24ELOn8mqOI6njUtJsh jw0+i49z6hbXOR81lqHu8qt+K2TIkye7lcw+TzGWE0QZhxP2EAxq1IZ8MMWPfe6KaJ55 tFAEfvPWSKzhU9bt+AVGOuHe1UDfUXupSQsMEOKu7BIGYLEe2Vhgls23cLpvceqB6Oht eZWGO9ARxCd/nqlvm/msVUpCaTnLjogkxo0DdweBOWhKyKU/zN/WBL4+H9AEcKfNBohh c/kQ== X-Gm-Message-State: AOJu0YwJPpf1Q5tmnMOGkw8PkNmUKUxhzNjg6ArXIIOc+G3ha/w/+9FH RmCkChFpcWGGH8K3tf1XyAH7vW6gw7yoEwu2+d8= X-Received: by 2002:a05:6a21:99a5:b0:14e:6c19:60f6 with SMTP id ve37-20020a056a2199a500b0014e6c1960f6mr1616975pzb.50.1693535024880; Thu, 31 Aug 2023 19:23:44 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 15/33] linux-user: Remove qemu_host_page_size from main Date: Thu, 31 Aug 2023 19:23:13 -0700 Message-Id: <20230901022331.115247-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::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 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 --- 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 96be354897..c1058abc3c 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -783,7 +783,7 @@ int main(int argc, char **argv, char **envp) } cpu_type = parse_cpu_option(cpu_model); - /* init tcg before creating CPUs and to get qemu_host_page_size */ + /* init tcg before creating CPUs */ { AccelState *accel = current_accel(); AccelClass *ac = ACCEL_GET_CLASS(accel); @@ -806,8 +806,10 @@ int main(int argc, char **argv, char **envp) */ max_reserved_va = MAX_RESERVED_VA(cpu); if (reserved_va != 0) { - if ((reserved_va + 1) % qemu_host_page_size) { - char *s = size_to_str(qemu_host_page_size); + int host_page_size = qemu_real_host_page_size(); + + if ((reserved_va + 1) % host_page_size) { + char *s = size_to_str(host_page_size); fprintf(stderr, "Reserved virtual address not aligned mod %s\n", s); g_free(s); exit(EXIT_FAILURE); @@ -904,7 +906,7 @@ int main(int argc, char **argv, char **envp) * If we're in a chroot with no /proc, fall back to 1 page. */ if (mmap_min_addr == 0) { - mmap_min_addr = qemu_host_page_size; + mmap_min_addr = qemu_real_host_page_size(); qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=0x%lx (fallback)\n", mmap_min_addr); From patchwork Fri Sep 1 02:23:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719471 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp16858lti; Thu, 31 Aug 2023 19:24:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6651kR4s8ntXTtS17ijSMBHwNBLFUgl7pYveSRDXZ/1alJvAhUWjlAbvw5R0NBFuFOqfZ X-Received: by 2002:a05:620a:819:b0:76e:fe06:2631 with SMTP id s25-20020a05620a081900b0076efe062631mr1186763qks.65.1693535095818; Thu, 31 Aug 2023 19:24:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535095; cv=none; d=google.com; s=arc-20160816; b=WNzQR4KX+7WE8xeMJxXfZrtidebDeCT9b9Dju66193Li1gqjYvrMlmMkaiLeVttYuy odoXTCyQ/vDq1ien7ZYocQ6Edb8zqCXrA/OO+UEFxR7uhg4fVerHiXlm1hY4LYkSqzg+ wP31pZVtT/90IqE0k95TuWf09Hz4N4PCko0qARtWzyuW02yJG4se67pBwqN4txknyKg/ 0e4e1GSXkEV6c+DsXc9E9IqtU+KgteVKhyFhaF+C8Mvl5nMnFoQEAkmeLhD9DWKbzMVa X+6IOI5JWSkJ615fA/wC9bog74ICXsAD45eI01pRBd4XQrdxeGQTkD4KsbQAy/nWAJfO yynQ== 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=UmUiHb3W9eyE4ZQAOrL3J/DCoQ07HdYWjlQFvdkx5l8=; fh=SfxhhCERWPFe9EfsSkQ0zw+VJgdUi+jLlAbxANM8dQo=; b=nh5vs/4zzfhaNIBxAACEj3bXEM+XNh3YicLS8ia3gI7vch7TFQOw7HEJc3l9k3zJBF sNybpW0sg0kG2/VRzTtClUBmmPRyIr+o3+rm8oT+mEDPwOzr0aoJ7P6xGoSAeLBCrYtK z54kkbz77dgK+hW0Asi6G9YDJjTr60gryXzJR0uFuKjROyz4nMfdzv0VKskbHnjxx+Qw YGDe9x3UgoW78k1/QIwYF4Q0bMhloroFVYm0lWz92PsZ+/zRhdc6AYh3Ks303AJuvBOo RCSC26RjIF6DKc9om2NxErKX0xZ3M+NP/u33h1IrbPR7zG6L1dKCMWGxPKUnwanHe2KG nRJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gHoSCd7A; 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 t9-20020a0c8d89000000b00649b7a60690si1728477qvb.384.2023.08.31.19.24.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:24:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gHoSCd7A; 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 1qbtp9-0006Z8-Eu; Thu, 31 Aug 2023 22:23:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtp7-0006Y3-IX for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:49 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtp5-0001Qa-2U for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:49 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-68bed2c786eso1248163b3a.0 for ; Thu, 31 Aug 2023 19:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535026; x=1694139826; 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=UmUiHb3W9eyE4ZQAOrL3J/DCoQ07HdYWjlQFvdkx5l8=; b=gHoSCd7AOZGxIMzRqF8hjSfwO0LK9vzzm4DZrcYpafm+zQtaLvTzCMpXUrxmX6mJrn 9o7q3cBBn+e6N+iLu9XEi0HpoL9/t+ZLJYzkIQG65q/ZupTspbTLOOfDgOFFO0HI6RKG G7EJuoGBhXcOcu5hg5N8JdqZMedYDpPGU6v00pho6dB+6gKlaaOdDMJ7t/2BM3/hji1x RWPgvJ72ggWbUlIhJEKHngG6Urjpa/H8N848O/enrKGP9nZfMqqmLJUee2uZr8czxJRl OecRpc71H9cLkRSHrkexchF68j3gYHpjB8JSzBfTT7RlFL5AcJCKvyr1Z6wdzIQ3faPB jFcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535026; x=1694139826; 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=UmUiHb3W9eyE4ZQAOrL3J/DCoQ07HdYWjlQFvdkx5l8=; b=PUNErCpmOUj5bNOMnkoiDXNwTutdSrrFeTFWPGA4xe2Evt6ki8Im5+03Zhm0DWc+pB DBiCvaQ6ZEfQzL41Cwc0IjruYo3ABvF8FZ3T0gn7Y49D3E8Hcmv3zTrhKXvJXdP2XA1Q 7XqYmT9EjFZbLCH6flnS+DvUXFf5gQUYM+uLiUti+Fm26lylwuS9J/Tmrbtffudx00fU MITxz7qNmUMx1xN7QPys53q6U1xVCxSXVZvYqeJ7pkFtiHo9Eeyevpgx0pkBXXBP99Ol t4lcRI9aLFvOaFs8ySAvFUxaH4kfKrxIlj+RxXWAaM64JIAChFFx/66M9oFn9C5svcJY enfA== X-Gm-Message-State: AOJu0Yy3beNsy8IOYMjSBkVD3Mw3gujAGbIB0V4TjPzd7WoYcUd+3khf oliJ7na9gSrIVdGeV0ifPmH/ExX7eEQ069uVGCs= X-Received: by 2002:a05:6a00:2385:b0:68c:6ebc:2210 with SMTP id f5-20020a056a00238500b0068c6ebc2210mr1566704pfc.18.1693535025755; Thu, 31 Aug 2023 19:23:45 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= Subject: [PATCH v2 16/33] linux-user: Split out target_mmap__locked Date: Thu, 31 Aug 2023 19:23:14 -0700 Message-Id: <20230901022331.115247-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 --- 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 35f270ec2e..448f168df1 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -446,9 +446,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; @@ -456,30 +456,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; } /* @@ -509,7 +506,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; } } @@ -530,7 +527,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?. */ @@ -557,7 +554,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; @@ -566,7 +563,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; } @@ -577,7 +574,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; @@ -589,14 +586,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; } /* @@ -627,17 +624,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); @@ -652,14 +649,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; } @@ -669,7 +666,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; } @@ -695,7 +692,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; @@ -728,11 +725,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 void mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) From patchwork Fri Sep 1 02:23:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719468 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp16770lti; Thu, 31 Aug 2023 19:24:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETfKO4zegbXGYQRrRo8kQc6ZskuwPAw3PMmzM1N+H3pSXA9xRzBAWROCysORXvBfIZldUi X-Received: by 2002:a05:622a:1c2:b0:403:b44a:a5e4 with SMTP id t2-20020a05622a01c200b00403b44aa5e4mr1608631qtw.52.1693535083831; Thu, 31 Aug 2023 19:24:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535083; cv=none; d=google.com; s=arc-20160816; b=ezAvCLVVgq265P5dcGeScjJkwVjsPYrOaQDmSg5ozS9q005UYJgrwQQCjOq2yYcs09 0tn2+/fyApKseBWvtoNr+8ZLl8GdfysknNHOnMafOjNDm1buFFaCAiYns3CvU/fPkj09 l4xZIqi0gqDX9IgDL2rHlEkdI3Xf0W1M3cpEOLOQneNkcyni06y2bqNF1BYqTfKSh8Ht MtN6t9fx7dF+L3LD8XMKwgkl2kR4SlCBnJMojUxe5H5qcHeKmerLKDc+DF1tUsrCANCG bGZvI5oQXrm5ANcr7tLH3hDm8jivibuM09iaYTJUzycfJ/Fzmn8TmBl2Q0t9e4LPOL4H 0eAQ== 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=u/C8gVjHYR4xtzLye5oGAh9WlueBxM9IX1xH8cPHtm8=; fh=SfxhhCERWPFe9EfsSkQ0zw+VJgdUi+jLlAbxANM8dQo=; b=jTk65AHqosTVtGLP6rz4vh2sGPRtRdk74sr7e7LsPfCu/+2SsjXGKKTUJbO1o5Y62V 6GhDKNvBJXDfR130bK+M7qQ3JI1Sy++JeqNsQXxLv1qH6hiTMLB/FN1BURL6vNm31Y19 pKAptPcINy4nkJx+fnl6YfRTIiWInAZFlJGetRKxmIw3mzg5ADvqTejYWYySq4f/fZN1 eNjGzOZ9L/nqt4wLI4hZskb1adl6tRRYAvWxb6paavQSZHQYkRw972+H0zu17WYw+eMA 5swtjVjyILWn740SLxLG6EQMsXIvwm4GNJNQQPT4uq4KXL52s0AsTccesNPbFAj6oqIC XNhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="A04/Oj5v"; 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 bp36-20020a05622a1ba400b0040fd5df3824si1780754qtb.36.2023.08.31.19.24.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:24:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="A04/Oj5v"; 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 1qbtp9-0006Ys-BS; Thu, 31 Aug 2023 22:23:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtp8-0006YK-4a for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:50 -0400 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtp5-0001Qm-On for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:49 -0400 Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3a85b9c6ccdso907131b6e.0 for ; Thu, 31 Aug 2023 19:23:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535026; x=1694139826; 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=u/C8gVjHYR4xtzLye5oGAh9WlueBxM9IX1xH8cPHtm8=; b=A04/Oj5vpw+9XMsincDcdd4kf2Hbgvt/cMD/5rA06VfBZ7waHGvenw2t0cVP324h9f k7AAFRCLRqwo9ODci3qAW+X2+hZUlCeuh19jXtgEnILSZ4+TpALy3yIk33oJyhPb/NZK emMJ2vB2DcjGmPY3wwMF+zxhvTNFShXL0tkxOKj4I84tAQ4WJHNfUeSEkOP+X4CWX2BX HgPdGh3f7A3mZbIFd3VjzT0fMeEknypoU1WJvSK69u01LAR0yBUXXgI34EI7cD2qrNoi D2y3u7rCbDvoiokTM/5WtyIP0dXtuxjvEij1OjS2ZnujO+nkTxJqyTKWfnI10hN6VpOD YBaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535026; x=1694139826; 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=u/C8gVjHYR4xtzLye5oGAh9WlueBxM9IX1xH8cPHtm8=; b=fuweONwPvHtxWCH39dHTz+WwTZ4AidLtwJyLzkrqPcux1VtWzLY51wgUewFPIBHnEo dgQQdS82h1h+Q298fZlktHeRpFu9vHksWO/DIPe5v/48qcB2jhcbfWmEyLF+3a0SHgh+ SwLkJ95yMnSH0ltyNVknKagTkQWNB7sfCxdi6586MEzOQGPmD5Lcw0tzdnnitw+ymCsT +1+MqsuD73o2pEOzLm5IRP1bK6fSVCcfDg7pdjnsGDuW9VYVjdLg9wluCQCnWZQmfHPy Yrt98ZGJ/eele0glPuDAYvOVuqAkQ7uHBfSdmlcIpqY3vA/a3HXCSBy5tTx50VghuuIp M48g== X-Gm-Message-State: AOJu0YziGb+mv+LihtNP4f2N8ul3C9y1AB1j6pqCOvhxq5W3H0Cl5wSD P9zRgVfJ50v7tAKrjMh6KWRHIDZOkmWrkXmjxnc= X-Received: by 2002:a05:6808:2091:b0:3a5:a607:650d with SMTP id s17-20020a056808209100b003a5a607650dmr1690031oiw.45.1693535026708; Thu, 31 Aug 2023 19:23:46 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= Subject: [PATCH v2 17/33] linux-user: Move some mmap checks outside the lock Date: Thu, 31 Aug 2023 19:23:15 -0700 Message-Id: <20230901022331.115247-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22e; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 --- 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 448f168df1..85d16a29c1 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -447,52 +447,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; @@ -572,23 +534,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)) { @@ -733,13 +681,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 Fri Sep 1 02:23:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719480 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17120lti; Thu, 31 Aug 2023 19:25:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFYPAQMVJok8CLlXObCsrfNcvvPKtfZzniYPmbJ8tfh2M2qg2NXJ+fsPSw0KJLgPBt4lhVQ X-Received: by 2002:a05:620a:28d0:b0:76e:f7f3:723e with SMTP id l16-20020a05620a28d000b0076ef7f3723emr5493658qkp.38.1693535143534; Thu, 31 Aug 2023 19:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535143; cv=none; d=google.com; s=arc-20160816; b=I4p8p6keG8epCZXTCOH3E/e41fI1IUBGtKaUliJ/SXJva8flpkf1VY0WfiHKtToh1c 5G++suYsspIplI5qrBGc7fNvHzzhiIeubBmB6edI7Uk7Zb50JvP4LZFqBL1qIDZMoUyp 4HoRIDjd6eoqCKe6oEulRyKNmtPMaRyVxFtQWySZuhKuhXXp4CCsCg1Xh+QzS9Et4dPG m9w4JpMkLghy8LTaG0kwoxfnfgNhl9AgukkPjZU2i8UeVNwHvmiAcn+Xh1HiqtgbDuBA rmzz7CBVDALZG7b4hC5isPm9hf70maxuw0iEgT1guZhJYYvbGFVey8bR9I6IVftjXKXm 6MZw== 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=5Yj/XvFLoTKPoAfaLaRz8qbNSbPbOFb4IFK3vAL5tQg=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=F9svPWaBJdyAJFcyeJn7VbiRI8N2gXhbn7cNt51WKvWSqVrakBDjiPZPKsV8XQffSK kEC8uDTxLm2JgdXT+Czl7pAGeBOutkzFllYXuRIyrzrFjhIEtPJUV5KQOn1dtuIavfcu aNIUtCJt4GCGnow8rG2GZcHcEzCD20JbweqLqpGojqR37uZAHMJ7v+1mAIVW3vqbXp3v GdIfsKTnhIzyrLbQTk3Zf0L8JKwkU+J6ia14ZJMBgjBIWAGveshxblrvxtKxCgckTpaI iVDRQXKYFehjLm8POSZ0BrcP9PCr4oZzZc7Ygjvin2twoGP9nDBJR36Y1fUWGOOZqFvb OlEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XABPTiZ9; 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 w1-20020a05622a134100b0040fd98ecce5si1615978qtk.716.2023.08.31.19.25.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:25:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XABPTiZ9; 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 1qbtpA-0006Zb-Hu; Thu, 31 Aug 2023 22:23:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtp9-0006Yn-7M for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:51 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtp7-0001R3-0f for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:50 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-68a3082c771so989200b3a.0 for ; Thu, 31 Aug 2023 19:23:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535027; x=1694139827; 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=5Yj/XvFLoTKPoAfaLaRz8qbNSbPbOFb4IFK3vAL5tQg=; b=XABPTiZ9amEnC07HAYUgC9z/MKERp6xwPFWTxjDg63bNaxUuUpS0BK/CXZlqqQE1hL V4loRxxi5UfALemjcj9gUrNubFE2HwhHTa+epL8SWhFffqlgPTbCoWwQgfBR9iyBpLpU rw3m6/QZhVfeaYLrxc3q5pmOM2etpj4iidhxejJybtBAjnfS0C97j17zDT3cJqpHocSj +AtN5LvHDjXDPKj5xXRS5kM7jcymsH7+8ZgEUa4bhBr8s1Ult6wyLbPHJevDGcuEngzY pMfp5oaF3R1Gi3SJkOyjICDO1/zG9XIUXtSAnGVmZuYDJKgZImMdrr8YzTyZBEoDxhWe +xbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535027; x=1694139827; 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=5Yj/XvFLoTKPoAfaLaRz8qbNSbPbOFb4IFK3vAL5tQg=; b=Sj5FpyQVV/+Ss62EbaDjkKV/GJOo1zJmb9SOBH+GU55n/PX/E9eBx0oGn80xyS3We6 HZb5mc8bxclo5YGavj17WyQbXp4/E6I0coqkl1TH9BfJooYZykUCJyHbjyDLjVokbfwN k3dfwnYKYdO2zvrFiELkjM0FBggnGhQ63afnUyoClkei7o42RCpaTwoD4biOk5CHnMga Eg/Y2Iz6UNke0F8+LsASe0Re0hie7bdvWbcA6TlE5XzY8wsm0Eb80uTvoppcppDQUM6g r8D9moSQac0ylo7pVmK+0lwf8XsgK9nUihaa6K4ao/XvhDP+pchdRenxFr0HTJO9RKp1 BFqg== X-Gm-Message-State: AOJu0Yz2Lzgo/tvZ/INIu6jaFQNxnmUxZsRoiYCjKF8eR82QjtKcziBc KVJx3mo7GvM2ZLiv6o7TiCC8d0jvCSPh9K/Mawc= X-Received: by 2002:a05:6a00:21c5:b0:68a:6734:b018 with SMTP id t5-20020a056a0021c500b0068a6734b018mr1750624pfj.15.1693535027597; Thu, 31 Aug 2023 19:23:47 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 18/33] linux-user: Fix sub-host-page mmap Date: Thu, 31 Aug 2023 19:23:16 -0700 Message-Id: <20230901022331.115247-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 --- 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 85d16a29c1..e905b1b8f2 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -599,7 +599,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, @@ -646,7 +646,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; } @@ -663,7 +663,6 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, page_set_flags(passthrough_last + 1, last, page_flags); } } - the_end: trace_target_mmap_complete(start); if (qemu_loglevel_mask(CPU_LOG_PAGE)) { FILE *f = qemu_log_trylock(); From patchwork Fri Sep 1 02:23:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719475 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17021lti; Thu, 31 Aug 2023 19:25:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5MmMSmmtPunx63r18cC4F4nS+p+1kh9JtYlbKcIFnKtMIxkFYcYXWqdOhtdyueiyCQski X-Received: by 2002:a05:622a:1752:b0:403:ca55:6ac5 with SMTP id l18-20020a05622a175200b00403ca556ac5mr1239848qtk.18.1693535123760; Thu, 31 Aug 2023 19:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535123; cv=none; d=google.com; s=arc-20160816; b=L3/DY7lZ87m24H0+q0qzhViNzmQMJGqKYaheKc/iLD1P9006auBP06nlB5A2OjJgIl IhICQ4BF921bHMxhf+uz3cNIZXaslNLHEMGN9dRt24vGgRicNq1lwFS/vzOIgwUhBHwP c8QDgTqVlwkNdWEwsRFyaAdTZSzEgApAqxeMIpDVZh7DY7cTFLRfS1u4DkGrr0fh1Ys1 maCaV2/F+Dtk1jr5Gca52R6qwzmfhrpvHvQiT0W1i7ooUkjSZHkmkCRjwvOXFuPu/5/+ WHi/j9oij0xsdLZZSNIJoIw4xmH4oFQvf0I6cXVvvppWbRCpVrGV/scqGV7LWlXYj2Vh c8dg== 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=JJ46g3X5MlXZj0BEFn3YDfl7TXV4QZY7r+Hh8MCrB4c=; fh=SfxhhCERWPFe9EfsSkQ0zw+VJgdUi+jLlAbxANM8dQo=; b=J4pA+nuz2QYsNJ0Xg8MMZ9zlntmmhjERKR95BHYaRNVkW+zCGhe+itbrEQoyFb+xf3 7bOO/P4Yvg4XmwZwFgb1psrQ4PVLcdcVNa9oLkqZRTAADNQE+3xdZdelPjWHyrsYEjY/ QzKB8ksKkANHvDiIQY9pGUv/UwZLkNcgOvo3J2cpoVxA0+zs7g5TM68Bo/VTe1OrH6GJ ivi7fmuWTfR7tq87FeP/bfiynwAOWZjfwDsY00LGKc/L3aNtDjjobTpzRHD6sofnot3U 0nssnr6zkULrHRUMLPH2c5pdLyktJrE5Inb6eAkv6HKq9P5oy/XYGOWYD+2O3lExOB6R ce2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iMrDTA3q; 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 u22-20020ac858d6000000b0040fd2f177a0si1690980qta.653.2023.08.31.19.25.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:25:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iMrDTA3q; 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 1qbtpC-0006aW-5m; Thu, 31 Aug 2023 22:23:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtpA-0006ZT-9G for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:52 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtp7-0001RF-Sx for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:52 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-68c3b9f85b7so1081011b3a.2 for ; Thu, 31 Aug 2023 19:23:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535028; x=1694139828; 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=JJ46g3X5MlXZj0BEFn3YDfl7TXV4QZY7r+Hh8MCrB4c=; b=iMrDTA3qlVYjAW6wa4ZF7CSXG4YVNyoe4KVU1M4djmVy3SDfwxEwoyDhs7GWozS3A4 WTdlsREe8pe2JuHjLzCt2zvNIkJ51DYltmQDFnI51Zj9wzlvYr9LUHcCRGy55VbPuu+I Ubgm5yDYuApPDt7ToGUBxwX4XM7hnoMlRfujGK7rmKhk0hz7egNNI9l9eytcYaVm4i8j XxpRNqpI4heC1P845a8F3RPIUpLXz2/e64iBrzfwJG+FUuAgoOdqhWQfglWvi/MfnjvX N0fCT0IqayCSso8PcHzSvLL6bLahd3Zbto4lQisgO+OT6G2cHVh49vtzrlGLFugeNteC 6woQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535028; x=1694139828; 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=JJ46g3X5MlXZj0BEFn3YDfl7TXV4QZY7r+Hh8MCrB4c=; b=E7+IWwTuy1x4iE/oLwVs+b3y5MTSZl9PdA6dMH71Aml1/XSaQNbtrwW5MIwQPqKc3D o6vIPgGBGemqj06kaYuicVCb+0P6oOg/jKhNIqdty0/zH9aoBnSY5KSRqaeHIDE4MPMQ YUD5LTsjBj+lmobJ5AZRHD31sxLKaKLXx0p+pC8jpeLPPbQf97/hg5aEsuHv3HZH8Fj7 KiKg7FA4StiU1TnNz2AfR5XB/avNxOHFuwPj/xKjY8iOuxFg0XZ2QkhSqiNBE+nCbj/P l4qUXlXpiQYLTN/Cpquu8Brk/KIiLLta6L7I/U3yyd5LfoWtt1s+mrCSTrNxW+HyVTPI ZJ8g== X-Gm-Message-State: AOJu0YwBk0RCCWCVf/UgVGuKKF0uTUcW9tLMWuxfAW1NUHo89cpaNzgV 3IHXfmk9cfuQfO22L2Emq3vQGsT7a9MuQJk9268= X-Received: by 2002:a05:6a00:3909:b0:68a:6808:3053 with SMTP id fh9-20020a056a00390900b0068a68083053mr1617749pfb.25.1693535028286; Thu, 31 Aug 2023 19:23:48 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= Subject: [PATCH v2 19/33] linux-user: Split out mmap_end Date: Thu, 31 Aug 2023 19:23:17 -0700 Message-Id: <20230901022331.115247-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use a subroutine instead of a goto within target_mmap__locked. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/mmap.c | 69 +++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index e905b1b8f2..caa76eb11a 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -446,6 +446,42 @@ 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); + } + } + 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) @@ -588,7 +624,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 */ @@ -599,7 +635,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, @@ -646,33 +682,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); - } - } - 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 Fri Sep 1 02:23:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719477 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17084lti; Thu, 31 Aug 2023 19:25:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHpDq+sCjJaTX1dqBFJ53QVNR9/OcRjcqe6uLA6Dbp09JW2xdc0v2D3VgER1HoUgJVntpwe X-Received: by 2002:a0c:f0c8:0:b0:641:894e:90fe with SMTP id d8-20020a0cf0c8000000b00641894e90femr807866qvl.61.1693535135315; Thu, 31 Aug 2023 19:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535135; cv=none; d=google.com; s=arc-20160816; b=cDyA2OKfbwqHfKnspC18ZVJogvWzWFh9n6wUT8QcPQBosRV8LdzeSKv0DXctix5J8L I23QU6TaK8Cpk1Y4GWsFFhMtEIdNUU0Y+0xY3tO7zHQU8Ad8ssRzLeFhh6sQmg8z2nl1 g2J/3CiRaNlLisqVd3yhGP3TNRKFylH7WhFnmLNizcs6qNylvZCs4qeimjL3RHJqjS5Q SwQg832Urf3nhjib/EtYvVtV3XPer/RqAFjRQ9Eit77TFK8+g7+mTlbSE8VNmClNBEAA F6Uf0prTWlT1VvX8quDfq4zSsK4mOvWSu6JMkMTp7XE+vu1c0AVYIU9a7D1dTRkeEDM6 XCyA== 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=7kaLhwLbHzHqv/PeQXejQChX9nX84J3A2xjA5ly6h/g=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=n8/5sUU6XCItDbytA4ttq1TivFfDJVedcLipYUQdyC0HG8pnA7lkBOp5n0hArt6fnG MC5pEzp2iwQfsPJf0cGDidubjCcmw/xdnW6zJvAShv/IYBDiJDVTJ03D/F5G8JnWyzY3 HRDYjAu19fnh577w1oyRi0cW28cUO/XYh8f32t6/OGddE/f1FGMwHwpSFvKnK4n5Befc qKi6es2QrExzuRHk2gDS5TgCLSa0Ox8MVnqAkPALLXKCsychubMAZfBkSHDKrG/CY0id D11I8SQiex5+Ie1XTy5x35tdI16G2dUV9l74bQbwzXGlNdA/KoqiHZbWeHuWHDxgoDz2 ANqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UhMnNGYX; 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 w25-20020a0cb559000000b0065160dd5cf9si1663751qvd.491.2023.08.31.19.25.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:25:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UhMnNGYX; 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 1qbtpC-0006aT-5x; Thu, 31 Aug 2023 22:23:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtpA-0006Za-Gp for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:52 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtp8-0001RW-Az for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:52 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-68c0d262933so1262880b3a.0 for ; Thu, 31 Aug 2023 19:23:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535029; x=1694139829; 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=7kaLhwLbHzHqv/PeQXejQChX9nX84J3A2xjA5ly6h/g=; b=UhMnNGYXFZr7WSTADl8NAcOgYpocmebTYMgxZ4PNBNqBQDWMF2EhtUfNea914Z/xfn Z4CXbhK971vODGPU/K+SvQNcQMQlhTfy2xD4mCyniUQgmByZ8OLtUygRxJ7Dx9bBbLYt PZENO2pq+Rk4r5crS0OlE7ubaNm5uazPfl+1ko9bprE6wisQH4IrWB1jm3Fl794gg/DF /fYBbqE3nh9QcBaId6fnICA5hLBGgNzE8eXrIAHTlk1Iez5cv/ZatmEBIz8iP18Z2O0j fjpi/b12RDL60kss8cWEPaLPFDLWRGSh6YZ038vnrUhbDWBq6jCAdoesbIrU0gEO2R5L g3oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535029; x=1694139829; 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=7kaLhwLbHzHqv/PeQXejQChX9nX84J3A2xjA5ly6h/g=; b=RP5HulJJCP4VFttTQSsp2zHIG6843S4IzrLgaVqzd28Lb5J5qsu9u5j6CwsVC4H5Sh n776XCnhq13iuxF19rcDfp+R1XA7Q9/3X7sXXRgmT6sEXwR105SUzp0207RTP75rlXh0 sXiYm9LPOeSZS1lY+iV722dEiD9ZntHDq4+2b6GHITexgAbuzKzVxpN8m2Kyl/voGaCt G6oHaQ9SoweBqJ/FwSnulIfBh7xqb23RkoM2MupE+rs8j+WuwPtZcFUSd9n1Dn3YA85b m+2qWB6uZxuNAX+pTGfvVYXrCD/QQ/oz/HzE21ReT7Hlz4+tR/GCT9G1BjAoGuSq8n+s XTUQ== X-Gm-Message-State: AOJu0YxuFjZ7y+rvtvqpcEMArcKy4Yjjo845GZXK7EgKvz47SN221NaY Kh3YD5eUcV4MEbqMUn69sCfo+Mm6fwFhB0Ix+NU= X-Received: by 2002:a05:6a00:2290:b0:682:713e:e520 with SMTP id f16-20020a056a00229000b00682713ee520mr1931675pfe.8.1693535029110; Thu, 31 Aug 2023 19:23:49 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 20/33] linux-user: Do early mmap placement only for reserved_va Date: Thu, 31 Aug 2023 19:23:18 -0700 Message-Id: <20230901022331.115247-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org For reserved_va, place all non-fixed maps then proceed as for MAP_FIXED. Signed-off-by: Richard Henderson --- 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 caa76eb11a..7d482df06d 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -495,17 +495,19 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, host_offset = offset & -host_page_size; /* - * If the user is asking for the kernel to find a location, do that - * before we truncate the length for mapping files below. + * For reserved_va, we are in full control of the allocation. + * Find a suitible hole and convert to MAP_FIXED. */ - if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { + if (reserved_va && !(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { host_len = len + offset - host_offset; - host_len = ROUND_UP(host_len, host_page_size); - start = mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); + start = mmap_find_vma(real_start, host_len, + MAX(host_page_size, TARGET_PAGE_SIZE)); if (start == (abi_ulong)-1) { errno = ENOMEM; return -1; } + start += offset - host_offset; + flags |= MAP_FIXED; } /* From patchwork Fri Sep 1 02:23:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719467 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp16730lti; Thu, 31 Aug 2023 19:24:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXmdk1eJDuKY8ZFpEjR0odRlrVkNtzyXjGgrpfJF8yRmXNIBr0u9ySgCQaKBlbXZmzyNsf X-Received: by 2002:a0c:f449:0:b0:63d:eef:c3f6 with SMTP id h9-20020a0cf449000000b0063d0eefc3f6mr1124379qvm.38.1693535078474; Thu, 31 Aug 2023 19:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535078; cv=none; d=google.com; s=arc-20160816; b=SEHoUM7fnF2Ki/9ORiJL5xj5ShNSvP8gFZCCz9ZMM6/ai3x5TXYk1gqOYjGtpDrOxV mCUhOzdWVPvEV96hEAJ3CIEqzqUraBkiLLfcmSKM24enyfBz1jszZEkLSiJZ4gXYez/Q M9Y0bgh0KD1dFAIovyTU+4h+MvLvdLJJ3AeR+VH0m3l3tshKaShj0mncSWzEe5m8qTaB QOpLnP8WR2BAVvKYK50FaxaM1Srm1FkmgtazjM1MyP3pDdehsOwb6hbkjuJCMwWBXP4t 9Ob3+fvVv0P2+yRMXzSmJs2VUh8MDAolM2+kjDQHoarPNvWlo+ORuPF9DBeVpTT3OFfl PcSg== 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=ySu5X2pwP/FjpufFI3frCgcVNyTN0K5y3i0eNXjPfK8=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=s+tqXwJn/7BnWZ59ghJVNGM/3hHCZu8n1w9NYBsYGJ/jOJ4OBaexmLlouHMA7vcMRX 0VjfHCpr69vWunet0CkCBjDfOfZAHHYW9QfiX80c4/BLnElN2CpVD7I8h9x8/nNwXIPb fN6AhqE7Nq6EqQOnZItbZ2w6d5fhj5z9BgZbcToOLMmqGuJNPAjDjmOvgGIbYsmsVRkk DUuzZ9pJ8DcYTaNgsciBXndKjdRfrIC1C0ODxWkZF5Zdg0smNg6KpNTTlMHaYUkV3ENd cxS6wv3x8w3D5UCVPRw9DvMAdNZZ83iN9lxLMhxhuylSotUULzJKP/DiXTLNlG9z8ukm kKcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=COZdD1pD; 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 ot6-20020a05620a818600b007680efdb225si1712899qkn.152.2023.08.31.19.24.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:24:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=COZdD1pD; 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 1qbtpF-0006be-Bf; Thu, 31 Aug 2023 22:23:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtpB-0006aJ-CT for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:53 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtp9-0001Rj-0t for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:53 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-68a6f6a66e1so1239906b3a.2 for ; Thu, 31 Aug 2023 19:23:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535030; x=1694139830; 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=ySu5X2pwP/FjpufFI3frCgcVNyTN0K5y3i0eNXjPfK8=; b=COZdD1pD9e7njNRlZ8m1pZdOMje/SwHzh0BqSB7/HcJc7FYesnjxycyfEv9My/1tAy MRzJv2jsgW2XpLZHyw3lyUkIG/NXwiBYAXbbw9aLryPieg/6nI2XsJR7rz8qFFqQX/B3 pB9L0DpuwD4naVqNO81m0gfztYLY8RuTKDHuFnd7MfoeeSNACL0N5wjx+K8dZA7wImTn pH12w8hjx7hFvIK4a1m/ESn1zlI/S9Z/CzOskucrK7IVlzkogudjsuwrCVFEL7mLTgtQ CVaGXREe4PYvAUb/FJl+vthH9Qpvfq/N+qAIeAqspWR+opS3ExIZpJHHXAzDSg07vj5j Nz6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535030; x=1694139830; 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=ySu5X2pwP/FjpufFI3frCgcVNyTN0K5y3i0eNXjPfK8=; b=KsX7r8juWiEbUWKcgwLzgkTevZzE9YnyBE3T1NSP8r1cWuDuGxshnepokqMt+BySdS JaLB1soT759deNWNtGsCXU6pFWox1X7wgmPpNhkJ0OS5/BCb5u3DXxU5u64exVZXMs30 fU4cVXzJ0p6q3xwjw7POj85AMkY1FrlywuscihR5v4iETGdvjsCqvaLtJxAzYOxIjRoY lzzjxZBhU0UwX80yTXHQXvD+x5ATVQkFCyqp1+WuWlr5nkgp7h0dnMuFjci7vgQp5zUQ xCWBCtqoT62JEr0Gpgam30HMTA98bAcYFYhE8FJ6TKfOoovIg+pVvuh5r6rd2mUCYI0y dWdg== X-Gm-Message-State: AOJu0YwTEPT5rzfYRm8akgVGGnnYAaqtVK8BnfIeEIqPYKwlUOz0kUOu EZnUCuN3a6SJLoHvpRc48Ff1Xt7SoR5nMyXlYRg= X-Received: by 2002:a05:6a00:c93:b0:68a:8552:c024 with SMTP id a19-20020a056a000c9300b0068a8552c024mr1962371pfv.7.1693535029813; Thu, 31 Aug 2023 19:23:49 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 21/33] linux-user: Split out mmap_h_eq_g Date: Thu, 31 Aug 2023 19:23:19 -0700 Message-Id: <20230901022331.115247-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Move the MAX_FIXED_NOREPLACE check for reserved_va earlier. Move the computation of host_prot earlier. Signed-off-by: Richard Henderson --- linux-user/mmap.c | 66 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 7d482df06d..7a0c0c1f35 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -482,6 +482,31 @@ static abi_long mmap_end(abi_ulong start, abi_ulong last, return start; } +/* + * Special case host page size == target page size, + * where there are no edge conditions. + */ +static abi_long mmap_h_eq_g(abi_ulong start, abi_ulong len, + int host_prot, int flags, int page_flags, + int fd, off_t offset) +{ + void *p, *want_p = g2h_untagged(start); + abi_ulong last; + + p = mmap(want_p, len, host_prot, flags, fd, offset); + if (p == MAP_FAILED) { + return -1; + } + if ((flags & MAP_FIXED_NOREPLACE) && p != want_p) { + errno = EEXIST; + return -1; + } + + start = h2g(p); + last = start + len - 1; + return mmap_end(start, last, start, last, flags, page_flags); +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_flags, int fd, off_t offset) @@ -490,6 +515,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; @@ -498,16 +524,33 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, * For reserved_va, we are in full control of the allocation. * Find a suitible hole and convert to MAP_FIXED. */ - if (reserved_va && !(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { - host_len = len + offset - host_offset; - start = mmap_find_vma(real_start, host_len, - MAX(host_page_size, TARGET_PAGE_SIZE)); - if (start == (abi_ulong)-1) { - errno = ENOMEM; - return -1; + if (reserved_va) { + if (flags & MAP_FIXED_NOREPLACE) { + /* Validate that the chosen range is empty. */ + if (!page_check_range_empty(start, start + len - 1)) { + errno = EEXIST; + return -1; + } + flags = (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED; + } else if (!(flags & MAP_FIXED)) { + size_t real_len = len + offset - host_offset; + abi_ulong align = MAX(host_page_size, TARGET_PAGE_SIZE); + + start = mmap_find_vma(real_start, real_len, align); + if (start == (abi_ulong)-1) { + errno = ENOMEM; + return -1; + } + start += offset - host_offset; + flags |= MAP_FIXED; } - start += offset - host_offset; - flags |= MAP_FIXED; + } + + host_prot = target_to_host_prot(target_prot); + + if (host_page_size == TARGET_PAGE_SIZE) { + return mmap_h_eq_g(start, len, host_prot, flags, + page_flags, fd, offset); } /* @@ -543,12 +586,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, @@ -671,8 +712,7 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, len1 = real_last - real_start + 1; want_p = g2h_untagged(real_start); - p = mmap(want_p, len1, target_to_host_prot(target_prot), - flags, fd, offset1); + p = mmap(want_p, len1, host_prot, flags, fd, offset1); if (p != want_p) { if (p != MAP_FAILED) { munmap(p, len1); From patchwork Fri Sep 1 02:23:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719466 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp16692lti; Thu, 31 Aug 2023 19:24:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGntJEYhHpMLqHz781F2buzE3gXRXMoBkV0xcthnFTzasalxx09MDPsqQEPAwpZBrfCUjVj X-Received: by 2002:a0c:f743:0:b0:64f:4dbf:b21a with SMTP id e3-20020a0cf743000000b0064f4dbfb21amr1044104qvo.29.1693535069263; Thu, 31 Aug 2023 19:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535069; cv=none; d=google.com; s=arc-20160816; b=DVoik/qVg77+EUoXATKUnNWMy/Ay9NkLKiOpcsMp+D0bF9I8IU3mSytVs3IsfCSIkR +mJbxXMJeRyUoNTZJcmCZM7IUB1JrdP2bJvUqy6fthO4UVuSjGjp0cXtDDNE34mYWGoT p3Mwj7Iw40p2D4qMV0OTCeuzUugPKj9NU59kGUKqnZTa29lOcgc83meH5p0Wz3ufzobs AYzf3QPpmz0KT2GoYvxVMIRID07fRERfdR6F3CDrF8mdREDS3Uv6qFnzcBz/M1Y9v6EF kaokGelM1axbErseCmeSoh4wgA0S5B+VGOSKv1alkcPfdPiuipidfqY6dqZQG16v6ugr +Wqw== 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=4bucLpoT0vquWNBuZLTOreK2BOdVySJCazC6PuHo6Rk=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=eyg4BlA9LFGHXvCrw4f/f3MkFjVCRYC4CIUiRt9ByoNBmBENmzSNu0cuBJlPNjWRYq seWUXvkPbMMSzsWHiQX2VYs692504/FCPyFqVdRPZexANi6njYXqogxLXSQXts+UIbkW Da6DQY8dfeSf+Xrr49IWF07w5irWJ1Qaktk2hRPgjuyDpxDjziIGt2IsfXnvYRJz9wgM vFyll5C1huN3xncsT9GOFXSJPJ/OoY4qZ7YEG9pQLBPPrT7Tp9bybLl4lX5/vwu/nZn+ O9d43jjNcWXzaGuE4hX0s6ca6r5KGWE+ZF6H0/ZBpsFKggufX+EvfoLcIBY/wJs6RUJn PWEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SUj97dq8; 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 w9-20020a0cb549000000b006408e52cad5si1764291qvd.485.2023.08.31.19.24.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:24:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SUj97dq8; 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 1qbtpM-0006ot-KN; Thu, 31 Aug 2023 22:24:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtpJ-0006f2-4o for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:01 -0400 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtpA-0001Rx-B0 for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:54 -0400 Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3a8506f5b73so952307b6e.0 for ; Thu, 31 Aug 2023 19:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535031; x=1694139831; 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=4bucLpoT0vquWNBuZLTOreK2BOdVySJCazC6PuHo6Rk=; b=SUj97dq8IhESm8KahCOejlOkTXlZyRvymOS405PszQ7fQQIlLgwrhEUcyRbTBI2y1a XK4JcfvPOkqqW6a9YJdzhJcm7oXixj81B/aPsix85ewa1dN08by4myyuONnSQFYd8F2W hT5MeMBEJ/YVu0686K8RJ/uSxaDI0bzK9Q4JTSmYkYtPpiKhGpccfQiOKhDDQa46QGXW hHpQ9qTrVxuFO3oDTydTlmCaLvpdpHSq6ufg7TXYoyx0IktYuHnXqZGgCj0IaZIGBdBW fI0qJdOHXxtpG6bUEIUv+/APhBDLK8GgBQe38ycKpvZBMp9fWdwOEHA/h5uYkmbqtNPE HZdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535031; x=1694139831; 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=4bucLpoT0vquWNBuZLTOreK2BOdVySJCazC6PuHo6Rk=; b=fw5JlcqVB+/3AXPKtGRgb47arpkRkA0v4TN0LS09c/Bi9kan4UsWG/k5p2XuKX2sRI 8p6Z+OgVNlazsSMk758u3jatOIX8T63J2MLCbaGueguUpsud1vhm90tuFbmAPNfqQYoQ aEA7rtIYmu3xgwNg3fTowt1gGB3DS7NsrA9EBZHwf17Li0JW8BoUc5OM8Q6NCNYaMp/S P/GZQJothSA9LbWC49kelGK0MVCEeF9u/hHEgjU1TghkOQsvY7y8b3si2IcK91GCqUA5 VGgZ9cpBwhRGLrJm+U5iHVqDdBdRZ3hhsteBU99Brb1RVZCc31pE7RQMgQxcLeIyKp5E dPSw== X-Gm-Message-State: AOJu0YzLvqsnLi2L4ve73Bd6ci399ZJORAvVYq7xMfFWdVSwaMv8hf3D cGA1GAaLlRFkvMBgj1pYf1rMENKqczuZcYJ0Lfs= X-Received: by 2002:a54:4e81:0:b0:3a7:2570:dcfc with SMTP id c1-20020a544e81000000b003a72570dcfcmr1394444oiy.43.1693535030830; Thu, 31 Aug 2023 19:23:50 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 22/33] linux-user: Split out mmap_h_lt_g Date: Thu, 31 Aug 2023 19:23:20 -0700 Message-Id: <20230901022331.115247-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22d; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 --- linux-user/mmap.c | 156 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 125 insertions(+), 31 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 7a0c0c1f35..ed82b4bb75 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -507,6 +507,128 @@ static abi_long mmap_h_eq_g(abi_ulong start, abi_ulong len, return mmap_end(start, last, start, last, flags, page_flags); } +/* + * Special case host page size < target page size. + * + * The two special cases are increased guest alignment, and mapping + * past the end of a file. + * + * When mapping files into a memory area larger than the file, + * accesses to pages beyond the file size will cause a SIGBUS. + * + * For example, if mmaping a file of 100 bytes on a host with 4K + * pages emulating a target with 8K pages, the target expects to + * be able to access the first 8K. But the host will trap us on + * any access beyond 4K. + * + * When emulating a target with a larger page-size than the hosts, + * we may need to truncate file maps at EOF and add extra anonymous + * pages up to the targets page boundary. + * + * This workaround only works for files that do not change. + * If the file is later extended (e.g. ftruncate), the SIGBUS + * vanishes and the proper behaviour is that changes within the + * anon page should be reflected in the file. + * + * However, this case is rather common with executable images, + * so the workaround is important for even trivial tests, whereas + * the mmap of of a file being extended is less common. + */ +static abi_long mmap_h_lt_g(abi_ulong start, abi_ulong len, int host_prot, + int mmap_flags, int page_flags, int fd, + off_t offset, int host_page_size) +{ + void *p, *want_p = g2h_untagged(start); + off_t fileend_adj = 0; + int flags = mmap_flags; + abi_ulong last, pass_last; + + if (!(flags & MAP_ANONYMOUS)) { + struct stat sb; + + if (fstat(fd, &sb) == -1) { + return -1; + } + if (offset >= sb.st_size) { + /* + * The entire map is beyond the end of the file. + * Transform it to an anonymous mapping. + */ + flags |= MAP_ANONYMOUS; + fd = -1; + offset = 0; + } else if (offset + len > sb.st_size) { + /* + * A portion of the map is beyond the end of the file. + * Truncate the file portion of the allocation. + */ + fileend_adj = offset + len - sb.st_size; + } + } + + if (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) { + if (fileend_adj) { + p = mmap(want_p, len, host_prot, flags | MAP_ANONYMOUS, -1, 0); + } else { + p = mmap(want_p, len, host_prot, flags, fd, offset); + } + if (p != want_p) { + if (p != MAP_FAILED) { + munmap(p, len); + errno = EEXIST; + } + return -1; + } + + if (fileend_adj) { + void *t = mmap(p, len - fileend_adj, host_prot, + (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED, + fd, offset); + assert(t != MAP_FAILED); + } + } else { + size_t host_len, part_len; + + /* + * Take care to align the host memory. Perform a larger anonymous + * allocation and extract the aligned portion. Remap the file on + * top of that. + */ + host_len = len + TARGET_PAGE_SIZE - host_page_size; + p = mmap(want_p, host_len, host_prot, flags | MAP_ANONYMOUS, -1, 0); + if (p == MAP_FAILED) { + return -1; + } + + part_len = (uintptr_t)p & (TARGET_PAGE_SIZE - 1); + if (part_len) { + part_len = TARGET_PAGE_SIZE - part_len; + munmap(p, part_len); + p += part_len; + host_len -= part_len; + } + if (len < host_len) { + munmap(p + len, host_len - len); + } + + if (!(flags & MAP_ANONYMOUS)) { + void *t = mmap(p, len - fileend_adj, host_prot, + flags | MAP_FIXED, fd, offset); + assert(t != MAP_FAILED); + } + + start = h2g(p); + } + + last = start + len - 1; + if (fileend_adj) { + pass_last = ROUND_UP(last - fileend_adj, host_page_size) - 1; + } else { + pass_last = last; + } + return mmap_end(start, last, start, pass_last, mmap_flags, page_flags); +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_flags, int fd, off_t offset) @@ -551,37 +673,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 Fri Sep 1 02:23:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719479 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17112lti; Thu, 31 Aug 2023 19:25:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFifW0x6YRrx6AuJjCP/t4HqmsjdXuwvNwqxFWEqK3hpuZLamJUVaDrxmsbyF88hvuN1kK7 X-Received: by 2002:a05:622a:1820:b0:3fd:e37c:edea with SMTP id t32-20020a05622a182000b003fde37cedeamr1831504qtc.45.1693535142336; Thu, 31 Aug 2023 19:25:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535142; cv=none; d=google.com; s=arc-20160816; b=PNsb7mkj8CUibCUC2BO4LC+j/ylbj378+cVupLseJ6YAiWeRUu6Zpmh+akjcPdg2ML aTdj8pbVox+qTrXbaGU8dLsI+QDoO8hKH7fgwMaFdbaopyY41I3xiH30uBS0sso50MAm UD2AZVHs0nzPHuZeiwS9j2TlR60rCXpJYtUoj+oeXnNs1ySnG277uGKIxszf+VaOIbIV vhitzYkVlYG4EWCep6UD/NbGJ4rO6fh3CsMs9KvBM4Gk6L5liWrimw/jNN8q/wPugenn kMecBbbPcGHmCTofxN7Te1EDPADjfsFo35oW2X+8/GRZMUuYqRVcODC/KKUooiDe4X2s wSUA== 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=NJQTkGtLKBIQbaCTGpYdZiGcCYcEb9NdqL6VTgxKtpE=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=a6wHoQZOrJruMXLF5Q6NaZeFHCUbwVVBQ6zkBknaHAQYw6rt0gGjSekIDwKZe3BMhj fGKHkIAdr1tjkvfj9D29u54B9EXpkxZ3oGEChnC340ageAROD1QAAb6q4ugNbGr9mGXR kfGz76JbYQeY0vs58i2e+TVAauYzO9Hjc/7BqtLM43pCZpScm0mRt58v4txOKTOiM2ZA 5QroFvnIMmaC/SEte1+aoSnMlR+14Zze2zma3A2fCTMrpdMfbLSFoJF9ReU1ripitFvV wkEYlc5pig8kA1Lis9nk074EfMLE5efUH1VC4FgFVOWrO8SdMxc47EBjr4CKVGfuMqpq CK7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pT6W9LoH; 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 s21-20020a05622a019500b004037607aac5si1673098qtw.276.2023.08.31.19.25.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:25:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pT6W9LoH; 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 1qbtpK-0006fZ-0Q; Thu, 31 Aug 2023 22:24:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtpJ-0006f5-5F for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:01 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtpB-0001S5-5P for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:55 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-68a6f6a66e1so1239917b3a.2 for ; Thu, 31 Aug 2023 19:23:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535031; x=1694139831; 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=NJQTkGtLKBIQbaCTGpYdZiGcCYcEb9NdqL6VTgxKtpE=; b=pT6W9LoHthTn0XoVvEcPFLkVicaYz1Y/EeXjvGuY2Kh9ICh3ha/hgZcYSgLiMzCk62 SRPpD3ni038XnNK2GFFN32xv7o27O2J9SUSvY3X6xinPj2N7S2RWyBqJMev9Y6HB5RLV 4GSkwvvX7gz7Z7SwZlmi7UCSqDfoZbJE4R8ExLtKHTbNIdsWX2/au7sGDEMYc1YHpwwd fJ0S57GzXXwPoy1yzoDy8OPkx3mqesRNN7s5pmmMa40co+Oep3ERJamMdhdSDKLK6OBp iswQlny5whkVC0cxPTndetJdl9eo+AWP3DlyfPeO8+42CrXsmwhG7m67i++84puQQ4jI /fbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535031; x=1694139831; 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=NJQTkGtLKBIQbaCTGpYdZiGcCYcEb9NdqL6VTgxKtpE=; b=EaaOLJkM3IcDvE2umtyUZvHgjbEbVSsKstSmpvVUIn876EXxpMZMzrksxai6HWWa0k cncGTP8HYBZJers+5chRFgllp636JGG3RssGdSpPdy3tChcCwA1WhyRfyYxtBXyx8h4m sXsT9Z86qftz9r+eSGkeOEh/+kmbF3c0UL1zIzmg5LJ3plNYDJDaB2YpAkZpOCqwWHi4 5yfLeWPgwr+96fQkpB9LgDqsfsvy3BWVufRhPPcd6b/Vr7zoOD2D3PUUVrXWrT84r1u1 0wy60uZTnv8mdsFQ9eqtLGA9WuTVdN0G93Ae5LwdiIvioBCNM1hRSnmFeIhuGWWSfx8b f6aw== X-Gm-Message-State: AOJu0YwrFZXBA8B14GlDUB5kkGHIqQ2CAUsyO+8hXzmcE1ir3KTeJ9F+ p5stEzwhXznK7/lLwlfJ/8odp3Y1pE68ZbdxTeA= X-Received: by 2002:a05:6a00:234c:b0:68b:c1a2:abca with SMTP id j12-20020a056a00234c00b0068bc1a2abcamr1509159pfj.14.1693535031578; Thu, 31 Aug 2023 19:23:51 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 23/33] linux-user: Split out mmap_h_gt_g Date: Thu, 31 Aug 2023 19:23:21 -0700 Message-Id: <20230901022331.115247-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson --- 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 ed82b4bb75..6ab2f35e6f 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -223,7 +223,16 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) return ret; } -/* map an incomplete host page */ +/* + * Map an incomplete host page. + * + * Here be dragons. This case will not work if there is an existing + * overlapping host page, which is file mapped, and for which the mapping + * is beyond the end of the file. In that case, we will see SIGBUS when + * trying to write a portion of this page. + * + * FIXME: Work around this with a temporary signal handler and longjmp. + */ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last, int prot, int flags, int fd, off_t offset) { @@ -629,19 +638,138 @@ static abi_long mmap_h_lt_g(abi_ulong start, abi_ulong len, int host_prot, return mmap_end(start, last, start, pass_last, mmap_flags, page_flags); } +/* + * Special case host page size > target page size. + * + * The two special cases are address and file offsets that are valid + * for the guest that cannot be directly represented by the host. + */ +static abi_long mmap_h_gt_g(abi_ulong start, abi_ulong len, + int target_prot, int host_prot, + int flags, int page_flags, int fd, + off_t offset, int host_page_size) +{ + void *p, *want_p = g2h_untagged(start); + off_t host_offset = offset & -host_page_size; + abi_ulong last, real_start, real_last; + bool misaligned_offset = false; + size_t host_len; + + if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { + /* + * Adjust the offset to something representable on the host. + */ + host_len = len + offset - host_offset; + p = mmap(want_p, host_len, host_prot, flags, fd, host_offset); + if (p == MAP_FAILED) { + return -1; + } + + /* Update start to the file position at offset. */ + p += offset - host_offset; + + start = h2g(p); + last = start + len - 1; + return mmap_end(start, last, start, last, flags, page_flags); + } + + if (!(flags & MAP_ANONYMOUS)) { + misaligned_offset = (start ^ offset) & (host_page_size - 1); + + /* + * The fallback for misalignment is a private mapping + read. + * This carries none of semantics required of MAP_SHARED. + */ + if (misaligned_offset && (flags & MAP_TYPE) != MAP_PRIVATE) { + errno = EINVAL; + return -1; + } + } + + last = start + len - 1; + real_start = start & -host_page_size; + real_last = ROUND_UP(last, host_page_size) - 1; + + /* + * Handle the start and end of the mapping. + */ + if (real_start < start) { + abi_ulong real_page_last = real_start + host_page_size - 1; + if (last <= real_page_last) { + /* Entire allocation a subset of one host page. */ + if (!mmap_frag(real_start, start, last, target_prot, + flags, fd, offset)) { + return -1; + } + return mmap_end(start, last, -1, 0, flags, page_flags); + } + + if (!mmap_frag(real_start, start, real_page_last, target_prot, + flags, fd, offset)) { + return -1; + } + real_start = real_page_last + 1; + } + + if (last < real_last) { + abi_ulong real_page_start = real_last - host_page_size + 1; + if (!mmap_frag(real_page_start, real_page_start, last, + target_prot, flags, fd, + offset + real_page_start - start)) { + return -1; + } + real_last = real_page_start - 1; + } + + if (real_start > real_last) { + return mmap_end(start, last, -1, 0, flags, page_flags); + } + + /* + * Handle the middle of the mapping. + */ + + host_len = real_last - real_start + 1; + want_p += real_start - start; + + if (flags & MAP_ANONYMOUS) { + p = mmap(want_p, host_len, host_prot, flags, -1, 0); + } else if (!misaligned_offset) { + p = mmap(want_p, host_len, host_prot, flags, fd, + offset + real_start - start); + } else { + p = mmap(want_p, host_len, host_prot | PROT_WRITE, + flags | MAP_ANONYMOUS, -1, 0); + } + if (p != want_p) { + if (p != MAP_FAILED) { + munmap(p, host_len); + errno = EEXIST; + } + return -1; + } + + if (misaligned_offset) { + /* TODO: The read could be short. */ + if (pread(fd, p, host_len, offset + real_start - start) != host_len) { + munmap(p, host_len); + return -1; + } + if (!(host_prot & PROT_WRITE)) { + mprotect(p, host_len, host_prot); + } + } + + return mmap_end(start, last, -1, 0, flags, page_flags); +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_flags, int fd, off_t offset) { int host_page_size = qemu_real_host_page_size(); - abi_ulong ret, last, real_start, real_last, retaddr, host_len; - abi_ulong passthrough_start = -1, passthrough_last = 0; - off_t host_offset; int host_prot; - real_start = start & -host_page_size; - host_offset = offset & -host_page_size; - /* * For reserved_va, we are in full control of the allocation. * Find a suitible hole and convert to MAP_FIXED. @@ -655,6 +783,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); @@ -676,150 +806,10 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, } else if (host_page_size < TARGET_PAGE_SIZE) { return mmap_h_lt_g(start, len, host_prot, flags, page_flags, fd, offset, host_page_size); - } - - if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { - uintptr_t host_start; - void *p; - - host_len = len + offset - host_offset; - host_len = ROUND_UP(host_len, host_page_size); - - /* Note: we prefer to control the mapping address. */ - p = mmap(g2h_untagged(start), host_len, host_prot, - flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); - if (p == MAP_FAILED) { - return -1; - } - /* update start so that it points to the file position at 'offset' */ - host_start = (uintptr_t)p; - if (!(flags & MAP_ANONYMOUS)) { - p = mmap(g2h_untagged(start), len, host_prot, - flags | MAP_FIXED, fd, host_offset); - if (p == MAP_FAILED) { - munmap(g2h_untagged(start), host_len); - return -1; - } - host_start += offset - host_offset; - } - start = h2g(host_start); - last = start + len - 1; - passthrough_start = start; - passthrough_last = last; } else { - last = start + len - 1; - real_last = ROUND_UP(last, host_page_size) - 1; - - if (flags & MAP_FIXED_NOREPLACE) { - /* Validate that the chosen range is empty. */ - if (!page_check_range_empty(start, last)) { - errno = EEXIST; - return -1; - } - - /* - * With reserved_va, the entire address space is mmaped in the - * host to ensure it isn't accidentally used for something else. - * We have just checked that the guest address is not mapped - * within the guest, but need to replace the host reservation. - * - * Without reserved_va, despite the guest address check above, - * keep MAP_FIXED_NOREPLACE so that the guest does not overwrite - * any host address mappings. - */ - if (reserved_va) { - flags = (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED; - } - } - - /* - * worst case: we cannot map the file because the offset is not - * aligned, so we read it - */ - if (!(flags & MAP_ANONYMOUS) && - (offset & (host_page_size - 1)) != (start & (host_page_size - 1))) { - /* - * msync() won't work here, so we return an error if write is - * possible while it is a shared mapping - */ - if ((flags & MAP_TYPE) == MAP_SHARED - && (target_prot & PROT_WRITE)) { - errno = EINVAL; - return -1; - } - retaddr = target_mmap(start, len, target_prot | PROT_WRITE, - (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) - | MAP_PRIVATE | MAP_ANONYMOUS, - -1, 0); - if (retaddr == -1) { - return -1; - } - if (pread(fd, g2h_untagged(start), len, offset) == -1) { - return -1; - } - if (!(target_prot & PROT_WRITE)) { - ret = target_mprotect(start, len, target_prot); - assert(ret == 0); - } - return mmap_end(start, last, -1, 0, flags, page_flags); - } - - /* handle the start of the mapping */ - if (start > real_start) { - if (real_last == real_start + host_page_size - 1) { - /* one single host page */ - if (!mmap_frag(real_start, start, last, - target_prot, flags, fd, offset)) { - return -1; - } - return mmap_end(start, last, -1, 0, flags, page_flags); - } - if (!mmap_frag(real_start, start, - real_start + host_page_size - 1, - target_prot, flags, fd, offset)) { - return -1; - } - real_start += host_page_size; - } - /* handle the end of the mapping */ - if (last < real_last) { - abi_ulong real_page = real_last - host_page_size + 1; - if (!mmap_frag(real_page, real_page, last, - target_prot, flags, fd, - offset + real_page - start)) { - return -1; - } - real_last -= host_page_size; - } - - /* map the middle (easier) */ - if (real_start < real_last) { - void *p, *want_p; - off_t offset1; - size_t len1; - - if (flags & MAP_ANONYMOUS) { - offset1 = 0; - } else { - offset1 = offset + real_start - start; - } - len1 = real_last - real_start + 1; - want_p = g2h_untagged(real_start); - - p = mmap(want_p, len1, host_prot, flags, fd, offset1); - if (p != want_p) { - if (p != MAP_FAILED) { - munmap(p, len1); - errno = EEXIST; - } - return -1; - } - passthrough_start = real_start; - passthrough_last = real_last; - } + return mmap_h_gt_g(start, len, target_prot, host_prot, flags, + page_flags, fd, offset, host_page_size); } - return mmap_end(start, last, passthrough_start, passthrough_last, - flags, page_flags); } /* NOTE: all the constants are the HOST ones */ From patchwork Fri Sep 1 02:23:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719483 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17372lti; Thu, 31 Aug 2023 19:26:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/FXxSPO8j3XTzALEuTdcRFcLgrTprvrC/Ufv47OaKxDjpbFAqJ8EQVzBVCMNXMYBtyoyD X-Received: by 2002:a05:622a:9:b0:410:9626:f0dc with SMTP id x9-20020a05622a000900b004109626f0dcmr1476675qtw.21.1693535189976; Thu, 31 Aug 2023 19:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535189; cv=none; d=google.com; s=arc-20160816; b=rY+R84nX4ol6O7tMwpT+hQbAHkFym3285Ak0FYMGNQqL0cmClkmRpg+XPeL8cW8T0Q ea8OUfYO6WFFS8Sy/KZlhYhUvTgJBOfhxPz8MXLIT+4eXZdlrv2FKLet7xatBoehFdc4 NvthwanRuS1KfRO7uQ3MFnr8G1NlR7owsT/k18zeMmYTWRDO2o0TNe/vQB1/QNGr6ISs sZyXsFU2REO55VcoI8HRK+F5wxuSHUyKYd6VA90dmFaCfK9QSgopnZ73t1NvFGqnXhV/ sZHYjoxXE9uBf0zw98GbxOl5Rpc5mxximEsvzh52QgjCnPUsvWCWKip6W5sS9wDoLnNV 7R3A== 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=JVa+6i7ltaDcVRVgM1SyKlnzNS7CnHg1qkG8lXGAgc8=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=k2iHkOElIc/fXHAJRXhg6EhbKIahFbo6m5zpXuXG5Y0gJgAvoWMarn1iAil6m9EG+F OV14cxVtZ5pvqHgpq2FDlI9y6DExXs5JiWtx72C5cIe1Dk0kUpHVX4jwO8uUSjvCnhmZ sUgkOOO5pvZQG8SH9l6EOje2X03tGpjZhES8nbIWCgAFDLYSm5GWJV8hGrMZ4jx4LPyS Q0YUB+uxYlOcryQ2PBShZ8hjE4MDe6AWwljGJWZHQ9UtnVdTP49S/hSLkm/dc+Dg8dbl Fl2nJLfWX5aQRVQTfwrgi+XslR302NP2QDxy4B5ldtaTW9Rgb4B2kZlQ8agdQ+h1sGFS kp/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="qiszB5/v"; 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 x18-20020ac85f12000000b00410993e39e8si1702057qta.260.2023.08.31.19.26.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:26:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="qiszB5/v"; 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 1qbtpb-0007M9-GL; Thu, 31 Aug 2023 22:24:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtpZ-0007Aj-JZ for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:17 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtpB-0001SL-PS for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:14 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-68c3b9f85b7so1081030b3a.2 for ; Thu, 31 Aug 2023 19:23:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535032; x=1694139832; 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=JVa+6i7ltaDcVRVgM1SyKlnzNS7CnHg1qkG8lXGAgc8=; b=qiszB5/vWDtROG5ij0czfJLP5wdQyCXIOeu2UFz0oJx/AbgH+xlEictvd/AI3JZjeD 1EIzFflWsdPvjvguMYHg6xQzuD22oHx3EeLNMcxk1wmFahuYx45LAwJde474RWepAWd9 0P6+pbvDYJiRAhjqbeAY4N06WRMtAZTI794wZePBB1SI1A5GiitJPH8yVPGSRxk8W2Da uSrxsCnn0haK3JS1uxDK2zS9S9vogafcILhAglRZ7Qfr0ifatA3ToS3VhwKC6zEyClSf ss4fBln2IuBGocGOHRpf3EL6dDrm0Gn7sXpGNWhT3l1qunTge+PktwO0SN79NGKrKaTk v4pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535032; x=1694139832; 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=JVa+6i7ltaDcVRVgM1SyKlnzNS7CnHg1qkG8lXGAgc8=; b=CpL2UYnipBxfWFI/SAD6LAuusUsFIW4KO9U1rvBHBUbNjm2Yj67WfBpO3nP5ZdBvTA ABoLLUSl8A6Qw3yfcETjdgacZ1LgwTqeas+C1eeZly+Jtz2SGIk/BmwCDBMkn3PCpkHm ZRc5j2VGM+RMnB1ZHP/l4TvgzI5tyACnDDuAJVFNhthGJNu3OLL0O6+Qo/usuIgFwCNE c6jKXJLGWTqEjQuGQbIfGgWEv+ly5jU/2KyrFcywlpbzry6+VJxzc1eDVZv+nwic+SYj u0a/62MFtvpiNFQwrM+OIQDf5vUcW1BRefOVws+0fbkw/whL7sX1rQY5I71j/0/X8DP7 /7ew== X-Gm-Message-State: AOJu0YyoCDL2Ls+QXsXsF/R6v+qbyrsQiz/OA1hSZOTj6l8TtOcG+l0n 5eM/pX6fX2qzoV0OECJnS6QuwEqkSYsYJmIj2Rc= X-Received: by 2002:a05:6a00:22c7:b0:68a:6193:710d with SMTP id f7-20020a056a0022c700b0068a6193710dmr1546133pfj.30.1693535032316; Thu, 31 Aug 2023 19:23:52 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 24/33] tests/tcg: Remove run-test-mmap-* Date: Thu, 31 Aug 2023 19:23:22 -0700 Message-Id: <20230901022331.115247-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 --- 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 0038cef02c..4b8c9c334e 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 fdf757c6ce..f64d7bfbf5 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 1163c7ef03..73a16aedd2 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 - -# 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 43bddeaf21..fa1ac190f2 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 ($(HAVE_GDB_BIN),) ifeq ($(HOST_GDB_SUPPORTS_ARCH),y) 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 Fri Sep 1 02:23:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719474 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17015lti; Thu, 31 Aug 2023 19:25:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpXGEQA10WiVBPPr8rUBCw3p3va6i9XltHiIjrX8Dz9Swwa6f14KV02w3C825Wh4OdlHPl X-Received: by 2002:a05:620a:7e5:b0:767:b196:e88 with SMTP id k5-20020a05620a07e500b00767b1960e88mr1127093qkk.42.1693535123168; Thu, 31 Aug 2023 19:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535123; cv=none; d=google.com; s=arc-20160816; b=xoU9OmDqAgNcZ1byjgny9Fk6HhgcOHA5kiUbOejcJtIFCi++kdIBiXAg6v8bc67QpX +cyw1WZ6GKfXJ+DmFO8IHeclO7GySHALRZ1AuP4BpMR7YLmkDZxP7nxpQPfgS0+jVIY3 ThGGo3M+YQ799nsub62Pf+n/89ROSG1ytkrDD77qq02ZBxYwcT0WITlSSKEW0hf9Cqqu uVygZEYqLpNdkixcZrxNvoz5neDI0qXorlAv6OTgXuQ8UktQ1INpr8Zi9txU3JfCf/Fu ua/3GNedFdx7as25LmwWPMd2GJ7rn6iXWIBO2kbnHWVqR4s/LH5WhgKu2ToNuPZ3E6J9 TnXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NKBqBWVnteg7nBg0Ct8xapNabPHsKvd3tq3kc9va8Z0=; fh=SfxhhCERWPFe9EfsSkQ0zw+VJgdUi+jLlAbxANM8dQo=; b=qZir6WwFBNSklAzjBVOpIIZZOI5ZoBdPArFYIbVGfirw0nDq9wJ+rFl8+OALGEXpum kaqHcWVkPNa+Emd6Dmx6ONXAMnyE9MTYhakbTcpkB2ySxTdnlIf8OXjTH+JqAlQJLwHA Z8MTGZCckqyQxDAM3N5//jW4GAuCBdsCzLrGwLaUWI70tKayqJ4YWyfZGJ46PFqmaYmk YG0Iti7Otpexfd1zJORQuzikvLaA/zA5vQmw+Ucri5ZDz9D3AWf0npB7ZC/jjuzsCHqO sQMgE8zpZfWsc9I8nzrOCG2nKCNgWrK8ZMA2ufZm9vontNAiQ857kBkLozrEraaPojDv y6gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nRjNEN53; 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 b2-20020a05620a088200b0076d9e0df338si1790737qka.377.2023.08.31.19.25.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:25:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nRjNEN53; 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 1qbtpT-0006wd-Gc; Thu, 31 Aug 2023 22:24:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtpR-0006wM-HD for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:09 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtpG-0001SX-RL for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:09 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-68a3ced3ec6so1287305b3a.1 for ; Thu, 31 Aug 2023 19:23:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535033; x=1694139833; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NKBqBWVnteg7nBg0Ct8xapNabPHsKvd3tq3kc9va8Z0=; b=nRjNEN53iW8r9Y5eWZONgwSvQ4WTdV6jcr+U9/LyPcHfsCjxsWUuwfvydxX/nbCr2h 4T3vs7JgWaCDZxVF3xp8AdDz5JXp2wCRe4/huTaZ0pzoeJFO4X/FwKFRr4DThpPGjItC 5bTqKldoWuKKTtKFGRCRFDLL4YA9Z/1YfvJCjaHNGQ7myAUOVInIFhez3YotG+XyDb87 s+EAgKhAgAJhsbYypI/NXuNbT14rQTA5rZJwQAhYgI67zK38e0cJOEuD7IAjQOOfMQdi Bqztp+mvFZu6DdOXntAbzo+WpU+pJAfZl5R92Zly1+8wR/qiqkJpVRIWoU9+lzqXPagy 4+vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535033; x=1694139833; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NKBqBWVnteg7nBg0Ct8xapNabPHsKvd3tq3kc9va8Z0=; b=h8zBQf9APAdkpriZ+BhBLFLLKOGLgZbqT0XhMcJESSxyoQpS9FQq6jdUNbYJjMPhT0 JlLzWLxc0lXlsSbXPjUjqnhm8WI5bjn8f0fiWP++MFYqvzUuxupDlZUyJQyTUDnlmo68 y4ZgWvXubt3zpWJ5tXKjm5Slwk56Ss4kwV2iD5+ThqpF4/c/iDh1DoCk+lltqPJUJSFO 4UVv8ipaWaJNuU4HyXA662pqB6VAArp2B/+0DsiV6VhCoHUZGLUAylDmMIom93n0q2IY 1NIrAUFKATRwZ+gZVc9llrsj6VyMYhG6IBI2B44zJfX5yvqbUZQ+dtro/U6hrIwE1M86 wd6Q== X-Gm-Message-State: AOJu0YwsDy0nJjq/kuE8hpHNjV38Plc4FALz+rUqCS4zRE1Nq4yNSsBX Mj/b2Y/3X4RjoDfcTSG6jFizIc+DKwHNmww9M9U= X-Received: by 2002:a05:6a20:8f15:b0:129:d944:2e65 with SMTP id b21-20020a056a208f1500b00129d9442e65mr1874328pzk.13.1693535033039; Thu, 31 Aug 2023 19:23:53 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= Subject: [PATCH v2 25/33] tests/tcg: Extend file in linux-madvise.c Date: Thu, 31 Aug 2023 19:23:23 -0700 Message-Id: <20230901022331.115247-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 --- 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 Fri Sep 1 02:23:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719491 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17902lti; Thu, 31 Aug 2023 19:28:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGTQXVkkmany0eczWK1/UXFlQbmHqJpxRj11WJUQQydgzs5gWIwS9FH94BhjpSWq+PnOzTI X-Received: by 2002:a0c:b34f:0:b0:64f:518d:ac96 with SMTP id a15-20020a0cb34f000000b0064f518dac96mr2092293qvf.12.1693535286175; Thu, 31 Aug 2023 19:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535286; cv=none; d=google.com; s=arc-20160816; b=gsHXH8qH0fY2vAPCKKw9JNVGqsQCt8VruIaLSruS6SKfkbzi2jXkVVxZVmxi7ULN2J ImNWMVlss19SI9M2terfeb9aOTmzDL51N29NfShGz2hAVFeVxMh/cAcfnBmaIGYscwq0 qUGKDU64//oc5Q8enJnvw6SmeTmOK29cKrXM19q30JhnKXtsOhm/mqQfXSnfss84iLDX Cjwc1kz4v9WkLYH/C7oBDI612SOPGab1hv65Y1BPpvcARZH5W4dfkR136JtpiRentN8V sAorVCCs5eLxlTTBbcYW9/2nKq2+0nwWRqgmZ6oOOmBfBmrbk68LFP/j1c26QjOALqVd imvA== 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=cWlmLzbT46bw9EM178vXYTWBMPDHKbwER57wNuihdYA=; fh=SfhD/LgK27FNnMp0IF1nMX/sVndr//Xqos8s7zD30Jg=; b=yfWkn+m+HmkAyJd5mntUXVcNAymAuGymlOLY4My4JzRcEUqPW1vdhchdfffkCFGcnO teyLXG+HdQzzxSZG0tpJPLNt6bCS0qH9HG3IXfYXIYYiIOwiDnLt2NTS4l3bunSk9vrV xgOGHhaOhPrIPepSAWMKGuiqSmnDhCJMu+1RqlQC8pt+0L8TNrQ0gUTziF+vnu0iU1rA g2cDsWDKohxjSS6q2Qk/jum5paOZvU2aW9vLL6iVJyiV+oxsQO0k0pUXL+pSoGdUuY4h 9YH5lDMnzgo9a/r09tr4yrTeI8Z+c4vsqChxPhJJJvY9bOU55Q+seTlhnUhdZjGPbLi2 rbUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kQWkOG2w; 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 s9-20020a0ce309000000b0064f8bdd0871si1765972qvl.365.2023.08.31.19.28.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:28:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kQWkOG2w; 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 1qbtpc-0007UO-F4; Thu, 31 Aug 2023 22:24:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtpZ-0007AW-IM for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:17 -0400 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 1qbtpI-0001Sh-Ty for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:11 -0400 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-56f84de64b9so938368a12.1 for ; Thu, 31 Aug 2023 19:23:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535034; x=1694139834; 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=cWlmLzbT46bw9EM178vXYTWBMPDHKbwER57wNuihdYA=; b=kQWkOG2wLtIiIwwLrHar4dkTT8VpAHROrHH9hW/s6RIrJw0NNmJxPU+qwtBbmVWFgr okmG40HLi1WdwLN08+TKfkx1mP86dXllV4S0o0ze4dGSLuZzn8iL4y3RDGV31KgoDVUH 3FrTi6bNnLFU3/+kJWJGObOwqtMRzjPhVoegH02eD95Tzmw1tS4FuO/GtBcI8J7jsMwM wjZucH4y4OMqq2ESDDhOf0+s8qwU3k7+Cob2Uw3jsPYpfPFQ/PJJL5llTWzdHNtePYRA rhlYbklra8TVsKWAo7LF077YxqS7PftYcrgRj6t790SiKq7LIGETcWcUx6SqvOoqd8cJ eKPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535034; x=1694139834; 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=cWlmLzbT46bw9EM178vXYTWBMPDHKbwER57wNuihdYA=; b=gg4zlnBXDGwCtIdqgeOoAIiYdIGhPkExHbgpzOd1TdNGIeTxROLgfuYUiyDNeRxHUG +41noovd9oqds4XOvoPJftsnxcuYf/dp5zrI7pdvAQvbdIrIPOwMVOOf7G6iB99JVo+W /HZZScKzR8aqh69kv/VMZFHUuGpfbXN/ZO3AXgp8ogaCjlfuwTgwzIriB+4/NwZIX3vL yK7V2mlrbyvAESgUEqTwS9h4emnMgAVrJFiI3PAq3M9JPo8IymgcgqYtvgIu8eWoDfqs dlmhVUePj5KuXDBrVx/ZFaHRwcpjvGYiB6F/bc23obnuWe+uxxanb6FkUdF737o/F9Wh lLmw== X-Gm-Message-State: AOJu0Ywd1avF/tFvJafu5UeDCUEMaKS7dvMCjl8GnoWdz+rplSwnBiL/ PCHi25TNH5pXS3c9cZSngPC/+66IN6h9tvU3IQs= X-Received: by 2002:a05:6a20:54a2:b0:133:38cb:2b93 with SMTP id i34-20020a056a2054a200b0013338cb2b93mr1802534pzk.9.1693535033856; Thu, 31 Aug 2023 19:23:53 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, Warner Losh Subject: [PATCH v2 26/33] *-user: Deprecate and disable -p pagesize Date: Thu, 31 Aug 2023 19:23:24 -0700 Message-Id: <20230901022331.115247-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::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 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. Cc: Warner Losh Signed-off-by: Richard Henderson --- docs/about/deprecated.rst | 7 +++++++ docs/user/main.rst | 3 --- bsd-user/main.c | 9 +++++---- linux-user/main.c | 11 ++++++----- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 92a2bafd2b..25f8220449 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -131,6 +131,13 @@ Use ``-accel tcg,one-insn-per-tb=on`` instead. User-mode emulator command line arguments ----------------------------------------- +``-p`` (since 8.2) +'''''''''''''''''' + +The ``-p`` option pretends to control the host page size. However, +it is not possible to change the host page size, and using the +option only causes failures. + ``-singlestep`` (since 8.1) ''''''''''''''''''''''''''' diff --git a/docs/user/main.rst b/docs/user/main.rst index f478635396..3a07be1278 100644 --- a/docs/user/main.rst +++ b/docs/user/main.rst @@ -87,9 +87,6 @@ Debug options: Activate logging of the specified items (use '-d help' for a list of log items) -``-p pagesize`` - Act as if the host page size was 'pagesize' bytes - ``-g port`` Wait gdb connection to port diff --git a/bsd-user/main.c b/bsd-user/main.c index f913cb55a7..f227d87834 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -365,10 +365,11 @@ int main(int argc, char **argv) } else if (!strcmp(r, "L")) { interp_prefix = argv[optind++]; } else if (!strcmp(r, "p")) { - qemu_host_page_size = atoi(argv[optind++]); - if (qemu_host_page_size == 0 || - (qemu_host_page_size & (qemu_host_page_size - 1)) != 0) { - fprintf(stderr, "page size must be a power of two\n"); + unsigned size, want = qemu_real_host_page_size(); + + if (qemu_strtoui(arg, NULL, 10, &size) || size != want) { + error_report("Deprecated page size option cannot " + "change host page size (%u)", want); exit(1); } } else if (!strcmp(r, "g")) { diff --git a/linux-user/main.c b/linux-user/main.c index c1058abc3c..3dd3310331 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -332,10 +332,11 @@ static void handle_arg_ld_prefix(const char *arg) static void handle_arg_pagesize(const char *arg) { - qemu_host_page_size = atoi(arg); - if (qemu_host_page_size == 0 || - (qemu_host_page_size & (qemu_host_page_size - 1)) != 0) { - fprintf(stderr, "page size must be a power of two\n"); + unsigned size, want = qemu_real_host_page_size(); + + if (qemu_strtoui(arg, NULL, 10, &size) || size != want) { + error_report("Deprecated page size option cannot " + "change host page size (%u)", want); exit(EXIT_FAILURE); } } @@ -496,7 +497,7 @@ static const struct qemu_argument arg_table[] = { {"D", "QEMU_LOG_FILENAME", true, handle_arg_log_filename, "logfile", "write logs to 'logfile' (default stderr)"}, {"p", "QEMU_PAGESIZE", true, handle_arg_pagesize, - "pagesize", "set the host page size to 'pagesize'"}, + "pagesize", "deprecated change to host page size"}, {"one-insn-per-tb", "QEMU_ONE_INSN_PER_TB", false, handle_arg_one_insn_per_tb, "", "run with one guest instruction per emulated TB"}, From patchwork Fri Sep 1 02:23:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719482 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17326lti; Thu, 31 Aug 2023 19:26:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFqq1gbXLr0LA8vYUX3vJmzDg14n0RDJOoOiedl/ZMumF6IySW8z5/4L+4Kk+MG+8o1SX0 X-Received: by 2002:ac8:5bc2:0:b0:412:288f:3853 with SMTP id b2-20020ac85bc2000000b00412288f3853mr1531910qtb.28.1693535180462; Thu, 31 Aug 2023 19:26:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535180; cv=none; d=google.com; s=arc-20160816; b=q2lj83Eae/OTZlOfIeouubflHP/heLcLRAKagbJvEaA+JDuy9qis0RJOywobwW1Y9i ax37Kvdj9NfrciPAKR0b/BpNZk8KzqRQxyRO8Il6BEkCpyA4vBdUjYypZqLiveUqUzTM 17f7hUGulYekMzsdnisbiEwerdIGdFUjg1jdD8bLe2LZ4S6gFaqVmxriD+bqpFu/m1tB n1nalkPXAg7Z9EpU4H6PIqVn01OZxog5YmwpJm49AQlWsguy5cIZI+euevUQpbSmvpyP DGl/aSYVdOeyb3dMwZ7ybeETT5ewkpV8xsKjh6lKAYoiYlScdvTXIPreOhtSovi/iTpT 5vzw== 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=g3/iatjXff6UUdz2cl7k/bF/yMUs8bwvdLM3Z+AtKOI=; fh=o6U65olpiChtTeyvLLJc8G2LwSIFblkR0bP1mmY+YS8=; b=HfNoLDyog5nlSS5XRr+JF+BSL6O0YgHy+Fl7L03RsIZ7khfXuKMo6KVAp4JQ9TCsd0 Z45bAUSXPghwFHCeE9RaOzKM/pbv97Yd+DrIfWlseU9ZIjnZdQ2HLkIdWKiryECRpNnK secMEzthy7pF0Uxj5fysVrIxuhEjOU/aijkugjq7Ps3pP2Or2PsprgU+LvFhZRe2BH6l 11Cd8gMJJEGB99cMslV1xVSDUfJxGkw+JGmVtzIWr51pPHzKcfDsC6quyT4hQTxFyRCV xXVpr5V1EFEx8Rj8eOsfPoul7LByNK0/fM6vxNAyNOZbgVB7viE3MupyLJjbcmTJOUcp evkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J0rDxM6j; 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 o19-20020ac87c53000000b00403ebb30761si1772148qtv.361.2023.08.31.19.26.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:26:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J0rDxM6j; 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 1qbtpd-0007Zv-6Y; Thu, 31 Aug 2023 22:24:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtpZ-0007Ah-Ja for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:17 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtpI-0001Sl-UG for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:11 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-68a41035828so1182381b3a.1 for ; Thu, 31 Aug 2023 19:23:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535034; x=1694139834; 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=g3/iatjXff6UUdz2cl7k/bF/yMUs8bwvdLM3Z+AtKOI=; b=J0rDxM6jGBYmkHZSIlGa37+7nlBgHAI2+laizxvHJqxkj8QIQSOo7pz2QOzv+ZVWYE 63mX8dzYjCtklPCYzbDlkiZqj9Z5B52Q1WCWXFyFFJ5KxA/ARDDjYuzG4XkueUP+qiRb fkl/lpGQXLP1n8sl1s6wWRYW4V5ojpRrZzLAoCz6V27w93L1Yn7KT/GuNhPfTooSU+h1 IYSCE+It6R/7g8lcaQH4N6TccRkEYKmDoULj297bQvwH1/rlx7fcDQBSJpeU6WQA/QO3 n4FeHIAgAPcaWT9OoXPXGwNbn6O38IVwVUFp0iiVUXGuniT8Zx/hY9cvL2lHUk0yeIoW HDGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535034; x=1694139834; 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=g3/iatjXff6UUdz2cl7k/bF/yMUs8bwvdLM3Z+AtKOI=; b=HwiXVJRzxoNJZRiguGh1PIgumInCfCA8Uq0TA6a2QnMSZE1GkyCzmdFy7pM3d6YHh1 HQN2W1dDGMXP7ZYH9pu0kFXgIuIIJA+A0W8M8Qy64/qRxOiNd2WWjn2Wpz4/YtXKrQqP 7ozh46F8uSGbAfJJoByUt8yveSqIksX6TmcNZhiJUiBItvV/vUxEodr8lGx3olmMj2Xz tSkzaCSgxeL5jEKmR+6weEpQ3AYxj8CyYKeVNMOoN4S1EmcV+xMIaux5aGhdAQ0AJ/i2 CAxOK5YVv35ygtK3qjjPtmgYENPjK7856IcwX+Q8exdDt3BVP6H/4prfAEdf2FzBA4hF r4+w== X-Gm-Message-State: AOJu0YxWcnOP0psaGClQhtDP7kICzeQ8OMvPkA7DYWY4VW2tlTcMVaT7 6QhTFaBI0TP2CpG78S/ZXFKqJlFziH2lBT2/RhU= X-Received: by 2002:a05:6a20:f39f:b0:14c:5f8:fb3e with SMTP id qr31-20020a056a20f39f00b0014c05f8fb3emr1444053pzb.38.1693535034680; Thu, 31 Aug 2023 19:23:54 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, Warner Losh , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 27/33] cpu: Remove page_size_init Date: Thu, 31 Aug 2023 19:23:25 -0700 Message-Id: <20230901022331.115247-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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. Cc: Warner Losh Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Warner Losh --- 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.c | 13 ------------- softmmu/vl.c | 1 - 7 files changed, 19 insertions(+), 24 deletions(-) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index d3158bc2ed..c53f06d3f6 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 41788c0bdd..46b0abc918 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -22,13 +22,6 @@ typedef uint64_t vaddr; void cpu_exec_init_all(void); void cpu_exec_step_atomic(CPUState *cpu); -/* Using intptr_t ensures that qemu_*_page_mask is sign-extended even - * when intptr_t is 32-bit and we are aligning a long long. - */ -extern uintptr_t qemu_host_page_size; -extern intptr_t qemu_host_page_mask; - -#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size) #define REAL_HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_real_host_page_size()) /* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */ diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index fdcbe87352..66575eec73 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -1025,8 +1025,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 b2d4e22c17..d84558dd95 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -255,7 +255,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 f227d87834..ab389aa938 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -49,6 +49,13 @@ #include "host-os.h" #include "target_arch_cpu.h" + +/* + * TODO: Remove these and rely only on qemu_real_host_page_size(). + */ +uintptr_t qemu_host_page_size; +intptr_t qemu_host_page_mask; + static bool opt_one_insn_per_tb; uintptr_t guest_base; bool have_guest_base; @@ -308,6 +315,9 @@ int main(int argc, char **argv) (void) envlist_setenv(envlist, *wrk); } + qemu_host_page_size = getpagesize(); + qemu_host_page_size = MAX(qemu_host_page_size, TARGET_PAGE_SIZE); + cpu_model = NULL; qemu_add_opts(&qemu_trace_opts); @@ -408,6 +418,8 @@ int main(int argc, char **argv) } } + qemu_host_page_mask = -qemu_host_page_size; + /* init debug */ { int mask = 0; diff --git a/cpu.c b/cpu.c index 1c948d1161..743c889ece 100644 --- a/cpu.c +++ b/cpu.c @@ -431,16 +431,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/softmmu/vl.c b/softmmu/vl.c index b0b96f67fa..bc2aab9aaa 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2049,7 +2049,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 Fri Sep 1 02:23:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719473 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp16953lti; Thu, 31 Aug 2023 19:25:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQ90PQtpEyWtqifY6NpMK5FZum/uJRrwTV/Wnk2o9qrkZ26tl78bhUEGSl4Pos4Iu3us6H X-Received: by 2002:ac8:5e13:0:b0:410:8bf0:6b1a with SMTP id h19-20020ac85e13000000b004108bf06b1amr1508856qtx.51.1693535114333; Thu, 31 Aug 2023 19:25:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535114; cv=none; d=google.com; s=arc-20160816; b=TfvUcDRSW9kjURztufWrrE4yFYxmG3CQ90OoJHdE999YaXhuEnF0WG/b9xuEI7bL/S ZwWnUGGltx26VOXrsA91X2okzkGcS2NpRcYeTaWYBMtLMgwQoCOYWMAbs3q0gwCVtrO5 UfT+sJwy/CC2KmsA5wzkfj5IOdSLj3l0PyKqZGdxNMpyeMERt5LFKc+wFJeLPNGqM8Zv Y/HAl8OUTf4DIKh6XWXVic7D4VbA6pFGpEE/T14bmOMmcc8rrCWo9ZeO3vFchNvLuxDr aogAfZ9WZ/iAYiJ5eFQiE09kU7Ol9wkwDX7WiO5ss4PIFXY8jWPTq48p2kOhVTOmetYd SFDQ== 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=v2oMFltgopchvkCHTnrNxCsJsKx6S/nBlH+XZvf6iJQ=; fh=SfxhhCERWPFe9EfsSkQ0zw+VJgdUi+jLlAbxANM8dQo=; b=PD1SDmzVr13w3VL+2TSlqPJGeIUTqYhfktow+tJ0S/96sdmb8DcTstaVbetpT/WU7m 4Eet6oOJPvV9VV9VHwJPnGS7u9bh6I+6P5STDPEyJbUlyTY1JjQlPP46WDldH7xrP8+D ebm4KLUnmC1QzBZ1u13N60uZnNOspf8Pq+1ypA7rwoShwW5tV0eQxDr+oNPF3BjrEuoq Br+/e9LczVd04ioE1ft9NmrNMMf2CnqtJzV3cWYMMetrzBby/uhnw/g9Uofx+F/17WYa XkYtWcXAaw6Vzb3KYFLa7i1m2msd4XRRY75uOgbFnXeuqDIsHXrYUgQkGLD98AhWeRzf 2+MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uQAacoMe; 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 j8-20020ac85c48000000b0040a11467cb6si1761882qtj.569.2023.08.31.19.25.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:25:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uQAacoMe; 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 1qbtpe-0007iF-OD; Thu, 31 Aug 2023 22:24:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtpZ-0007Aw-M7 for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:17 -0400 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtpJ-0001St-VQ for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:13 -0400 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-1c26bb27feeso960863fac.0 for ; Thu, 31 Aug 2023 19:23:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535035; x=1694139835; 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=v2oMFltgopchvkCHTnrNxCsJsKx6S/nBlH+XZvf6iJQ=; b=uQAacoMe2WjDYLW0a/J/nKVA7w/hLcOTOn6aS9DCQ5TJB+VvahbbScmhjVUXXA7Dpn cnspQc+B18oKBa343SW4kMEu3C+SrvIBa+uWYDUpmUj3gJ6tp99n400BzHcrKYYyWd2T l9CvXQysmkX2i6elqlfThbFG4KnOzhIvoxe+JKqAhvgg8a5mbxrCO2CI5oo4uCN5UIfI P0Xp4/sfqxN20/QuSfM3TAe2wQnH91yzBFp9iR69nnpz+eqEYE7AMZqCOl2ZcNSNdZPD GyB9t7OVuFZ+V/Fz1qde/+2pl/m2yDH9/jpwNeJv1VXMemzRghv+ipEiZQhAWz0HTqBt eF9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535035; x=1694139835; 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=v2oMFltgopchvkCHTnrNxCsJsKx6S/nBlH+XZvf6iJQ=; b=dzxa+Vxo6OVKuCf7gYoSSf1xOjvXG1tGpTwEMF0Vt14VupbQoDqwyYJE6xjDZvHcYj /4EeAz6Nspa/XS0Wem+KHfd0bPctvA+G0PG9bT8LSy8Y5joqTihcjkiwdPa8N+jXRKQc P5yz7Z85jmO/Gy2xjncPK/aelDwUwHYKhHgHGK31zRmMoDBddwca5RUbtjuvr/XDhKx6 IhDg+Bp86AjnbkQAaav5tQ3hw3lZie24Y9jdCVTkV42zZb0tgGhczZM2H5t4PPGwrjGZ 4b9VOjVl9z25l61kSVtyQ8Fp8luEBxy9RE2V/T2qLUI1di0yfgqki9xc3hQTzJnm1t1R Yh9w== X-Gm-Message-State: AOJu0Yw6+ZF0kqUu1cTbJ1MVQGG1AIJ3yuOew/7pODt16RdCElsGQCX5 AtuG8BJ5Kyvc1ia2SXImb4GIQvh2Le26Ek0yD5U= X-Received: by 2002:a05:6870:7021:b0:1b4:4a2e:33f1 with SMTP id u33-20020a056870702100b001b44a2e33f1mr1523556oae.29.1693535035472; Thu, 31 Aug 2023 19:23:55 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= Subject: [PATCH v2 28/33] accel/tcg: Disconnect TargetPageDataNode from page size Date: Thu, 31 Aug 2023 19:23:26 -0700 Message-Id: <20230901022331.115247-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::36; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x36.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 --- 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 4c1697500a..09dc85c851 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -863,7 +863,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; @@ -901,7 +901,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); } } @@ -909,7 +910,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; @@ -925,7 +926,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; @@ -935,7 +937,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 Fri Sep 1 02:23:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719490 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17868lti; Thu, 31 Aug 2023 19:27:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxsRxA0qxqagn3+OiLd1apDre40to/iH0nUICnUMMu1zvEpp+zMvmWK30s7jkWPsjlrr4f X-Received: by 2002:a05:622a:3d2:b0:404:e64:f5ad with SMTP id k18-20020a05622a03d200b004040e64f5admr1644184qtx.47.1693535278276; Thu, 31 Aug 2023 19:27:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535278; cv=none; d=google.com; s=arc-20160816; b=ER3JbtUUMbDruDuQEZqy2mk8fr8VlFBU+BsQgb/W9Nx96Z77EgzWaAHeDsPN1zjScW Jz6dVu38lc0QIUfQSOklUqiwotJqu3L3Jwlj+rHzPjzEy4utX5SRymPz+vrBOD3n4ZQw tx2aNsQFQPguLvFjExVAAEw7Mm5AbFopaESCXOIE7Wb1aeoRbD1RrYeYPeIz6qH7/j/q r8wljk8RVP7Zt5Zdxm9Rf8u9WEn7HxqAt8Jf4yGLmUTR00Pe18LfPAJa+u2bdKXpM9I6 kRKn/a1fExOhnudCaTjhucaq7nDvWZ1SSDjWKLYVMkimhOPPaM8S3Ap1p/VZSNiXdAjS 9DWw== 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=KOXbHO/eFtWrlIqiHiO0rtMkzoeNCBbWRU+OxOKa9Pg=; fh=SfxhhCERWPFe9EfsSkQ0zw+VJgdUi+jLlAbxANM8dQo=; b=WxcxxBPjg7f168sfB68Y4mI+expqE1kBLQ7mgB+J1WGVTG+tAksYkL36Ujr8oGdg/4 FrLJZPOw7mrDX5+BG682KMVhuNuI7Ofpmb5WtIKa+iFL8ty3tZ0IGBmvPBTQV4zELf/X 9uOHu5jZLkwJNUro5UeX+YqhGd/45/1p7xvAqbVzZVyjsVILBnz1+B0WGOgVN8q6K46/ P5QcB+VBHiNxfQqCoqzo5oA3r26THvLyrrq8wcRX/cQ0s7iXNgJ3VDMv1FzZKwSAOXVo MSUOdn0EzqoiOZ3rPNKQpHB1thkZCoSV8eVEQUcdtRP9hy3k4rSWJc/YvU8V/azLhlqV RJrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="inRF/wIb"; 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 6-20020ac85946000000b00403b10c3cc9si1690206qtz.270.2023.08.31.19.27.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:27:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="inRF/wIb"; 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 1qbtpc-0007UL-Ec; Thu, 31 Aug 2023 22:24:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtpZ-0007Av-M0 for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:17 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtpI-0001T0-UL for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:11 -0400 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so1091528a12.1 for ; Thu, 31 Aug 2023 19:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535036; x=1694139836; 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=KOXbHO/eFtWrlIqiHiO0rtMkzoeNCBbWRU+OxOKa9Pg=; b=inRF/wIbPYAhx3xn9OImu7t1+i4IYcVQ43dyWzrinH31pSeVLJd5H9fvfumvird95H 5YBI7SHn2S15x5+YUTVoXn3P2mhqvQNCF9/Ivc49M4D8/vUFpNLez3KW9TU+Q4BBQ6G6 EkNV5WLIjOmvKzQl/fnYSTHWE5d9AiQffE4avgMtpcomxgnSNDF+hVcH0MjZZudvvUaQ mvyJwPPti9iUz3M4QVIuJW9SmGaPca8g6+1o/qH1XtJ1A6NoEzp4wR0HW920rEjtaz03 +AGxsX6Pi3zb0/sqduv3h5QU7Z18/p1413zPpjVtTe8VgkE5N6jOp2wURUwcvcYbC+r4 AyhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535036; x=1694139836; 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=KOXbHO/eFtWrlIqiHiO0rtMkzoeNCBbWRU+OxOKa9Pg=; b=OKRGsTob/Sed0utydteh4inQWCU8YpM0sz57g+kTOahmZbxLNh4Ff2oVxdW7Lnt2gF HtfvHU/ZCc9GXtWGqT5HhwpoopIEW2dS+SpDUtVzuIzPjMh679KcKyK81r4LxNTaZCX5 e8VDV91/Q7Qg9jxz/tbHVUvXpM0cqmYS76R2XD9Eql/WFraPRTEDJUnLSC0/oM/h02KW RuSBOAnyiOAscMomEavxMCjo+CkCSou9C4IODx9zSuo59ut7iEupJAiCwar321syfvqG Kt2XB5uvQNPZgDxWPhJG2rYUkHYlt/XvQePOxRy8mdzIZXJzcittwORYV6i0vD3vU5Xz ipGw== X-Gm-Message-State: AOJu0Yza50rgPOmP5rIXpgV9YxKDQSrdj/PAqfY3aVPJXuNvrUQU7qV0 BaiH8XHnXAMNzPY4FTKBHWb5t9xnSL5dWtv/6Eo= X-Received: by 2002:a05:6a20:a122:b0:14c:6438:eece with SMTP id q34-20020a056a20a12200b0014c6438eecemr1581864pzk.62.1693535036197; Thu, 31 Aug 2023 19:23:56 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= Subject: [PATCH v2 29/33] linux-user: Allow TARGET_PAGE_BITS_VARY Date: Thu, 31 Aug 2023 19:23:27 -0700 Message-Id: <20230901022331.115247-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org If set, match the host and guest page sizes. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/main.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 3dd3310331..2334d7cc67 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -55,6 +55,7 @@ #include "loader.h" #include "user-mmap.h" #include "accel/tcg/perf.h" +#include "exec/page-vary.h" #ifdef CONFIG_SEMIHOSTING #include "semihosting/semihost.h" @@ -683,6 +684,7 @@ int main(int argc, char **argv, char **envp) int i; int ret; int execfd; + int host_page_size; unsigned long max_reserved_va; bool preserve_argv0; @@ -794,6 +796,16 @@ int main(int argc, char **argv, char **envp) opt_one_insn_per_tb, &error_abort); ac->init_machine(NULL); } + + /* + * Finalize page size before creating CPUs. + * This will do nothing if !TARGET_PAGE_BITS_VARY. + * The most efficient setting is to match the host. + */ + host_page_size = qemu_real_host_page_size(); + set_preferred_target_page_bits(ctz32(host_page_size)); + finalize_target_page_bits(); + cpu = cpu_create(cpu_type); env = cpu->env_ptr; cpu_reset(cpu); @@ -807,8 +819,6 @@ int main(int argc, char **argv, char **envp) */ max_reserved_va = MAX_RESERVED_VA(cpu); if (reserved_va != 0) { - int host_page_size = qemu_real_host_page_size(); - if ((reserved_va + 1) % host_page_size) { char *s = size_to_str(host_page_size); fprintf(stderr, "Reserved virtual address not aligned mod %s\n", s); @@ -907,7 +917,7 @@ int main(int argc, char **argv, char **envp) * If we're in a chroot with no /proc, fall back to 1 page. */ if (mmap_min_addr == 0) { - mmap_min_addr = qemu_real_host_page_size(); + mmap_min_addr = host_page_size; qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=0x%lx (fallback)\n", mmap_min_addr); From patchwork Fri Sep 1 02:23:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719487 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17746lti; Thu, 31 Aug 2023 19:27:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGc56hs15+xSsQQKHPT+qn8N3RBsi4Rf0fGZCTgKoEzhBBcYVSTxYhQYx/FaAUrKVsdesuZ X-Received: by 2002:a0c:f34a:0:b0:651:5d9d:b099 with SMTP id e10-20020a0cf34a000000b006515d9db099mr933293qvm.38.1693535258130; Thu, 31 Aug 2023 19:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535258; cv=none; d=google.com; s=arc-20160816; b=LQQpe63DJxzOahomZogd99JyODZlBFbOHesnjFxvBl+Uf/Vi+rowxA1vW9GxyrROFh 3ASUoawDlRqyEYlhE0s9E6lduoWkLwNYuNkQ4K3ySs5iV+vQATGm2rq7gbYUgdc2DZ31 V2Tu77k1YlSo9OL5m0AqNZMKF/E/Rp8Lk/l8bNdU1apd5vlG2VhL/G7N5bTPMTh5KflA p/mUCvsecuiMaestgiOQGdYsa9E290z8RDZ/kjd7vRwrmajCVbBGEB+kvw1fC54hkLWH xglnjIV3ptLviyJzgHd6Em0QfpRJY5RqTMMzE2BNEdS+CEWEMUCrAEiDc8EpuuSix+No 4HKA== 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=fbLJWfbE0uDldMuy5F+fdwCnCFNULQlG9yJoCgwPGqM=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=csnr7g3618hoaa+cujbMSul87Jjtewkf+tSITi4I/aRTrFYJqM3PSQcki0eVE+s4br ULbSsFH9HqGSJQbXqArSGe/TxasnL0zODdjdVtixyBNO8fLiIIhJR17hS8exFWTAVfch k4eRKTpQVOfN1YY11iZiaKRPduoLsf2AXhPfU9UXddPXP7iKsjZtGai0tP1XO7TrStiC sSYcqHKMjy7/MsNDUprPvGTxsqNC0KkgEiCaYkJt94VIomZfmeHInrMQ8i25H8TDIPFE YfErUHrESKggzoMxvl/V448XDr2CYVc02LbblVUxh6SBR4LXDhBFFR0cMw/E7vKp+HsW mPrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y07PYSOA; 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 fh14-20020a0562141a0e00b006262e701f90si1875870qvb.583.2023.08.31.19.27.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:27:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y07PYSOA; 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 1qbtpg-0007to-FT; Thu, 31 Aug 2023 22:24:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtpZ-0007B0-Lu for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:17 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtpJ-0001T6-VZ for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:13 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-68bed2c786eso1248222b3a.0 for ; Thu, 31 Aug 2023 19:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535037; x=1694139837; 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=fbLJWfbE0uDldMuy5F+fdwCnCFNULQlG9yJoCgwPGqM=; b=Y07PYSOA3at28omsk7WOB5YcsEnjMdOdbBO2CtSW9KBBEEcNuk5+ucba4J90aJJ9zt TpZGYxpFzzfKEWo3Q/B6oWeaMhLKHr78WioeiOyfdyOfAiiwAfVQZi5iHndX1uuOE+4I hZUpaLqNruFIDgLaFfjkpghS0OSjmdm7nhiI2vlBqwCqr24OPS3f55cuEytvFBiqq9yj loYy+mTbBbo1gkzps7fkguMI/vmfmyMgbEWc6L9JQ94UEGG7ZiOCfh/O2y8FYPdXhkTe 9E0CVeFJuf2u2S7bryVQclNEQ9StqZFMaFL1itnjbmCiW5W8+J8qivvEYDI8gfTT9qJE qKzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535037; x=1694139837; 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=fbLJWfbE0uDldMuy5F+fdwCnCFNULQlG9yJoCgwPGqM=; b=ia5m5C0S6VtxIzAPNzpcPTWjlAeN6n1qFsBQ1PTM45EEWp991dnt4CwP+J1DisOeLi WcosRQyoIeGXP9kqp7ku3ORGWfopIivsbeZtrd/m5w/HYYyJ6kaQFJsDDGyyCc4Lxiou Q+X7yRDPrn718yURN2VrAxqD+QIy9hP8mYtXcE9TsZWgeAZFaxGHwnrXYLo4j1xoxICz eLzIdviZ+gNgQvoZPJWpuRgiL9jViXPOK42Z/8f9MWPyLYZoWhupSrfn6XGOaWWF2wOd kqprImWFORg/EIxeROjbAKWkmIg0pgtfV0CK4a1HSu23F34d1nu4gEJBibk1EAw/3vpe JmrQ== X-Gm-Message-State: AOJu0YzMIaEFhKDH3zJccBuYfoubvfFewWl5WWZoX9dU6XGAm0VSwxZ8 ExkBTPnNG25Ald/Mxo6g9Ghc7y4/ns2ZIdi7lJs= X-Received: by 2002:a05:6a00:99c:b0:68a:5937:ea97 with SMTP id u28-20020a056a00099c00b0068a5937ea97mr1711751pfg.34.1693535036918; Thu, 31 Aug 2023 19:23:56 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 30/33] target/arm: Enable TARGET_PAGE_BITS_VARY for AArch64 user-only Date: Thu, 31 Aug 2023 19:23:28 -0700 Message-Id: <20230901022331.115247-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 --- 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 b3b35f7aa1..7585a810b2 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 0bb0585441..de2a90e23d 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1677,7 +1677,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) ARMCPU *cpu = ARM_CPU(dev); ARMCPUClass *acc = ARM_CPU_GET_CLASS(dev); CPUARMState *env = &cpu->env; - int pagebits; Error *local_err = NULL; /* Use pc-relative instructions in system-mode */ @@ -1968,28 +1967,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 Fri Sep 1 02:23:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719492 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17990lti; Thu, 31 Aug 2023 19:28:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9/OjdaO/Xa1fwU60YyQVpTnkF/Ssv3WWkdU6g+QciV4cN1mwoqjXshldY35cyq37vBmFz X-Received: by 2002:a05:622a:152:b0:412:30bc:1d70 with SMTP id v18-20020a05622a015200b0041230bc1d70mr1588993qtw.14.1693535297623; Thu, 31 Aug 2023 19:28:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535297; cv=none; d=google.com; s=arc-20160816; b=LKJIToLARDB2T740aROLT3R4lYMSuYbTP6jhHrnSMZE3QUACcjtPMUpvR21zx01/d6 dk9ohjPYzII7qm+6xue8eT31Rmzv5h8SrsqSJKiyDamXgCAoN5fM89KHOk1e661ygWd9 DFQOm950iGPiibZD1oFeurIlToHovFBEgWQ9ryrneiyY7LyI8wIecppGxlKCZlrLI1hh 61iymJm1p++W6ybUv2+me2uplHETrKhjvQqtgf+W5elPQ3zy1wcaECYqQLcau6uLNft1 WyBPtaHcULgSiFayTuXpQPK0QfJIQm8f9K2KVv5yX4774k2y1va+MA9OvlW64wFCmvL/ ZckQ== 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=sLGhrncusZ++ow/925hmU4zhHqvG6lKeFI4gVIL5/yk=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=xd7ePCf8j8L31qwyDUM6+ZqfNnCX/64Nmi8SD34kaegHIhLpjvHyBNhDVUsss7bQZ6 lzxxOC8RXAsGhX1e9yEAaV6GcCh5aLALHcMgZmeXzrRWZmuIVnDXp1S+QKl0dyUyGat3 ogOWUPtUB9UQbsaOhUZ8ci3oz7MmZOWwrUJIypdvjxQemrvFEVleuXm/FQ7UN+ase+G2 EnHIaTPTMz9nyASmL1LSceV5LGacucRPhf1cvTYiN2LvV5CG0GCpvfGywkwVeMhAkriv POVf/yClQT6yrpZS3oaqNIoVva6Oy40g9bevK4EZdBY2jC4k0DZHdDcsrT1RMHWykGZf 26Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MC9RrsQh; 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 v5-20020a05622a014500b0040fc209cc9bsi1763237qtw.1.2023.08.31.19.28.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:28:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MC9RrsQh; 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 1qbtpb-0007MQ-I6; Thu, 31 Aug 2023 22:24:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtpZ-0007Au-M7 for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:17 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtpI-0001TD-UR for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:11 -0400 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-565e387000fso1084723a12.2 for ; Thu, 31 Aug 2023 19:23:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535038; x=1694139838; 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=sLGhrncusZ++ow/925hmU4zhHqvG6lKeFI4gVIL5/yk=; b=MC9RrsQhoxf7zK5tuJ/orKfao4N0GffyQT1rTK4416+08fqoufUVxRtrHsbwPV7lWe Z8rtEFT1DYixQgq2J4LB5IDxWsiBWyXSFSo7xauZ7qto4qXPBdXfc8ju0TSLrA6AC2QT mRPHK6YBJ7tX3NfhyRr5gw19lOEYfuMRcvn+kp5GkSnkoH4UIKebwsvRMdRfG8U0O2an HIGEpuIE2yZnfyS1hd6Qu0KkU79Hiqh3hfsiCHVYQnkaHurEIUVgwyKhPV5y/7Yq/jOw Mmj00U4CKRTfStbQyM/+NBVXGLLldMv4Sr8T5H9/6wWwj0J0LyFrW4hKvdW4cHidtc5C S01g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535038; x=1694139838; 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=sLGhrncusZ++ow/925hmU4zhHqvG6lKeFI4gVIL5/yk=; b=cJzvYPlRx0Jf7LPk1dZacBLANdXkd98WHIDvFjrjM1uNxmS5RMsQuxZaZfWJKypCrl cZkuDd1GVBSnMGqnJV5inwyFPrmPZQ3ak5RWPo87w7dGiomdUavOhoui56SjIB89LC1N LLVV/lGGopSYeIKTE72stLphe16JR0AEgmBQWFQSpIMthmg5uHZfYQPwqrTbUyK14ieH tU4OJrljA8fRM/FspXvOcky6lv7R1u1gqlFF/17Dx78rRvcO0xA427sOwbC7H0vCIb8S p3Kn6EQqOfpJrP2z3RFcO4tCv2VqRo/HOrse0zc8Us17xNCRbbmRhvDLlL4o/ocNT0OY +RSw== X-Gm-Message-State: AOJu0Yyi++SObs4i0lVBUGw4A48OtcEtkF5hlUKRN/qvOBovMUjwlFRn a2Uzwbd5Aepwxw5IZ+ay+07YMto8QMcCqhH0XEM= X-Received: by 2002:a05:6a21:3b49:b0:14c:d494:77d0 with SMTP id zy9-20020a056a213b4900b0014cd49477d0mr1392208pzb.26.1693535037741; Thu, 31 Aug 2023 19:23:57 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 31/33] linux-user: Bound mmap_min_addr by host page size Date: Thu, 31 Aug 2023 19:23:29 -0700 Message-Id: <20230901022331.115247-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 --- 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 2334d7cc67..1925c275ed 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -904,7 +904,7 @@ int main(int argc, char **argv, char **envp) if ((fp = fopen("/proc/sys/vm/mmap_min_addr", "r")) != NULL) { unsigned long tmp; if (fscanf(fp, "%lu", &tmp) == 1 && tmp != 0) { - mmap_min_addr = tmp; + mmap_min_addr = MAX(tmp, host_page_size); qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=0x%lx\n", mmap_min_addr); } From patchwork Fri Sep 1 02:23:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719493 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17991lti; Thu, 31 Aug 2023 19:28:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF1jSb0zvMi91PDRlMeFPpEwe+H2O4+ynH7LtvXg+THzTX5sS7N3EVDW+QI9Ob+D0vGIz8q X-Received: by 2002:ac8:7f0c:0:b0:410:a073:7538 with SMTP id f12-20020ac87f0c000000b00410a0737538mr1470151qtk.29.1693535297738; Thu, 31 Aug 2023 19:28:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535297; cv=none; d=google.com; s=arc-20160816; b=iOwn+J9A4JNZANd5jrcanNBI5YWtZNqW1+AisoDwwgCJGY7kcpNClH2W4l9n2a+d4p 3nyYUBUngf999BHzrJW52U/kBA5wU+E84CyKm5tXbgcs+pu6T8WLiEqzg1ohxCMkfnTf yzOOx6aN2tnS1Wap8mqiyOAsqOKuzvaRVb9KoIU13E8XXBKRmS4TRbY7hRtLfhJ3Awkr xYC6QF4NCyiKuAOQa8fz8JCSGE/6IYZtMHTW0/RiRrQ1G/VI2u6ufwPkMV7n47cWo52Y VB3UcDzg04tjN7nCx7p//ebEFD9Y550nkLo7zveZSHocAmJOGkeGGUaLqdTGYo/hAxtI JPpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YzcEJzTW0FxXggtPi1Qrm/hCkn19peXK5YmTgg9HZqo=; fh=SfxhhCERWPFe9EfsSkQ0zw+VJgdUi+jLlAbxANM8dQo=; b=CJHtMaT1Uoynd0r88m0cniAyVqnbHKMw2SEpj+Q1bL/OImaW5YexTo8OAcsvaRLw2l QwoLSAkkxbZsxCLqS7oF1FFvtjtwKI3SjIpyan2v93SHvQfm2QoHvwyDRH6blmjAhue5 SX80x0wAFLt4iyTzsWyMqLrV+fn74YNDXv1Bh+AD18eUC83QrjgBcUPVmgJaYRydzNoM njkPg+0anEM67hocsCg6QkyyVNtZ46EL8HdJDjN1G4T1IgT1Wydl/13R++U7QWFR7r9a VoLvu45GGmALbjg9cmpOaK/kGpd5cmm2AFJajiiRFFSEDEamDkZwDQqbvTqn4Pabs0Gq gndw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jyT2CQd6; 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 u15-20020a05622a010f00b0040ca95dea94si1751062qtw.6.2023.08.31.19.28.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:28:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jyT2CQd6; 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 1qbtpb-0007LW-Et; Thu, 31 Aug 2023 22:24:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtpZ-0007B2-Mb for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:17 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtpJ-0001TM-Vf for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:13 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-68a410316a2so1254094b3a.0 for ; Thu, 31 Aug 2023 19:24:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535038; x=1694139838; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YzcEJzTW0FxXggtPi1Qrm/hCkn19peXK5YmTgg9HZqo=; b=jyT2CQd6B/rywZOwyuojhg5esUhVLkKFczrXXF9re3qbvDuY3XFJqKaPAGHHLusDsI DS7e6YhX9JcPyOXWb97XfEVIh5Mxcwn2/GnxQkeQQqIOfeFhBN6pMTMo1jziFeHhzVk2 zLbqyGoJF62XYN6IdtMv8/Str46uJpjL7uZPnEQBqNr+9/dcSkQO0bFQ9PdD3i//Vaa7 TXaH6BjXiOGWYqabz/UZUw0MrqSwjYFLqxuIhNgOpu77wU51Bu1zlUKMvv5Oe8CdQhUE MyCV02yy2FYeYZI0zdfJsPhTY/H3lwbxyGEXVc9HExNY6Ta0u7yqHA2BO9z99CiazmpE xVZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535038; x=1694139838; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YzcEJzTW0FxXggtPi1Qrm/hCkn19peXK5YmTgg9HZqo=; b=QZBiMdrbB6y1hvUCmUP1UcrTZB0QHy68WJdd94r9PdXW466ggkATMa0RGx1feiQOZY hGPXo/MEHBa/a3g69liTVzLMTOSc9sEmeSQ7hCHhmAWsc7nHxaewhKvGk7Gq3tmkfzRH 4i+vt3PgVi1mWspY1dc0mkov2iOoRjo5Ts3YPxa4MS4H4Omo49tGwMw1g/2WuAtPY9DF 4xkvVhH4i54+s9BcXakM3maF9NFslPAJijMX02bdkOp9dgn6NbWPfvRaoJI4B5rcvNMS G7mbZ8+9NA32NUrZaTdREZmJ9iUtiYdJXdM6z7Q61oBhBF+2JvqIetn5yCozmgSEPWkl NDVw== X-Gm-Message-State: AOJu0Yxx1YJvn5GOm9TRu9iumkewef/3VYhjfLCJGqZ50ljJv1ZAHFhQ 2sHP4la1Bo8ZnstVf+IQe+lYtfoSGzTg/v9Rql4= X-Received: by 2002:a05:6a21:7903:b0:13d:ac08:6b79 with SMTP id bg3-20020a056a21790300b0013dac086b79mr1278500pzc.60.1693535038559; Thu, 31 Aug 2023 19:23:58 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= Subject: [PATCH v2 32/33] target/ppc: Enable TARGET_PAGE_BITS_VARY for user-only Date: Thu, 31 Aug 2023 19:23:30 -0700 Message-Id: <20230901022331.115247-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 --- 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 Fri Sep 1 02:23:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719481 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17184lti; Thu, 31 Aug 2023 19:25:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8SZ3Ss+6dY1P7EXQpFBmZhcUZLS8p9T92PXa1TtQmc+qnNglTuuxzWjWDZmXBdUzTFvQ8 X-Received: by 2002:a0c:b31d:0:b0:647:16e7:c5c8 with SMTP id s29-20020a0cb31d000000b0064716e7c5c8mr1171899qve.11.1693535151177; Thu, 31 Aug 2023 19:25:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535151; cv=none; d=google.com; s=arc-20160816; b=jdu41at+pcAamzQfI0xHKpPwshW4aTkI/AyBMtSTRuK+T2KMxcFEoGoRsrmTsJFKTI 6elDragB+Qp3UdB+4Wce+LWok/CJwrVoBbQt5v0rHw3LKe42/ZhceByAdPZOZ+KzgV9O +SmH1xncK0zpLmPbWHyhsGgBMRDr7GoSRmjlk6h9sJsOGh30fvQi5NNMFsBUlaQ0bMyL 1eXjicRU5yJB5x3xLJramZPd2cZVC5M3e46Wt0fN28f7FiR/LB4Bpxc4ojBNudDu9yMn idJZKPepW8Xb6cIew9k2F9MUMtKsizbEI5bXOuAJ7M/xxcC8PyZ/ikQZo8Nrm+M8j7/A 7Vrg== 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=UM3G3JW9WxcLT5Dzb3w4vT9giwKkE+uVqc4Wz3d/fxQ=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=x6c6yEVMYmcElZc5oT1wtoSiCFwkStJR8D3xNNvZuYzJRyYITODRWw80S+D34cTBU2 MPGCmOKLRLwf2PZr79kql/zV1W0pkVNSWvl2RMq3hmnweot9b6LYTtQBbBjsgTEEu+We VPjwDIuqaz/iJkP4A9vgPVOhS4aTa1mFC/0zKl9TdZPBrqmsa/H5+g4sHq9FEf89C3nq kEQTVAQjhTxmEWr2LAJlXrh21hliv1gKLLaaOyd3tAi2a8Rj7vG7mjMPPcyLj5zx1xJ0 Z6t/S6zwBVViudwVP1xGnUVIfQ/Rc+4u/Ym9wCk8eZY+gSyuVHElEdlXyAR96sDMHVFO LXfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FzDh7kdF; 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 h1-20020a0cf401000000b0064c6b7d96e1si1682279qvl.372.2023.08.31.19.25.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:25:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FzDh7kdF; 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 1qbtph-000808-Dw; Thu, 31 Aug 2023 22:24:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbtpZ-0007B5-Mv for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:17 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtpJ-0001TK-Vk for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:13 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-68a56401b9aso1248220b3a.1 for ; Thu, 31 Aug 2023 19:24:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535039; x=1694139839; 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=UM3G3JW9WxcLT5Dzb3w4vT9giwKkE+uVqc4Wz3d/fxQ=; b=FzDh7kdFcl+ICqiOH8saF6XwJwMc1DcChe0vxWHjxEx8s0Xu1OaH+DnNrWMw0je2zD K8ho8r9LXLBPDrP4yW9aj9Hnrs4+qKz1CDeSlqrwPGqfROKC0CQVc1tbgCylJ0hBZS0Z rNazWYATamlcc1Cfo/A29qR7s+mCtqWmQM6/JRBh1xcCSt3QVvgl96knfAHtVQM+FBGb 7cNFbE3oMSgrAZ2E8ZX4mDJkeU0PyS5MjKsoJtRQsGPt4XherlwDfUumqFgyfHVCR1Lu OuNURzgqUJOM1ripkxTug2KwiVZL2dQJHB/TFsY3WuHj2C8Zyt4ZmKnRGja6XOK+BQiE RPhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535039; x=1694139839; 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=UM3G3JW9WxcLT5Dzb3w4vT9giwKkE+uVqc4Wz3d/fxQ=; b=NXUurHzwqoZ4r3SYpem0jjV0MWNyGiZToKEnUk1mwRcCfcfvBpE81nYfRFkEktmEVq 3zNEZ3OS0yug+4mFP9A+tGHmgKAbGq5s0QotYm2o8dQPiVEE4AB97QaOsqNkdw0QXUIT UWDG3UcTVXSsQnynOmWLpXdcNPzPvb4d5TLJHFTYhlP9sMZSY4swoiXk1hD1xUIeKkQy LDwkRMnXepy+KKCzBMcsoNnRztns08tw2GiCNfjvKC9JRky9CfRM0mbkFRD+2McZL/nI c7GxdoHGVXQUluKLJMbDnh2C6KdStkxYQvNes1djINnzTqrxb93CFtvws33FHfKNznSm 7xEA== X-Gm-Message-State: AOJu0YxnsRfccGFdfoMfL3Aex2OP995+VBHCqU+7BUbAA3o7ZM0L1Cva iLrnmdM29CzktBtX2tMjZvFIuAX6PUcvN1qtA3A= X-Received: by 2002:a05:6a20:157:b0:12f:c61e:7cac with SMTP id 23-20020a056a20015700b0012fc61e7cacmr1470526pzs.31.1693535039263; Thu, 31 Aug 2023 19:23:59 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 33/33] target/alpha: Enable TARGET_PAGE_BITS_VARY for user-only Date: Thu, 31 Aug 2023 19:23:31 -0700 Message-Id: <20230901022331.115247-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 --- 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