From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535039; cv=none; d=zohomail.com; s=zohoarc; b=ZNBtQ+DmLwGhwTjhgtQlwLwvuH2aLjVl9NIAfA9bpmZ0hoOS+HREGzP6nWPLYjK2svHWxZ598n+N7nSzeISVFnPzhjLzS6+/d9x6qgh5xplkMKKRBB20OhhTdmr4bOd1927nLl91pXoK9tPz/nrtr1kFiHdX+Ukr1X9GQYdUK/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535039; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X0ddZs7bYg6jrh/HugPDxFYzx9+2rJ0wZJYAYZEah5o=; b=NT1sYkfjZHIf26eXr1gv6eId1PJbFHEl+nZIwUIvPTbUGxQ8W3hCf69x7YuVOj2oiJaRJmXSc4YeQCnOMLNoMUllUwtZSS1uvxpiLqPLHgP5lqj2ILH46Fklm5dUlBv/OH4xu4GevAeM0E3eRhsbs8DOK6kv+CHZIKburDQryHg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535039472410.79830735365; Thu, 31 Aug 2023 19:23:59 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IGyqcCx1LSeaj+QgdzlBR8X+07dimRq54ZuitamRx+tRYsFnbvGnKKFNCSGCdMwHeXNB/pSjA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535040597100001 Content-Type: text/plain; charset="utf-8" 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 =3D qemu_real_host_page_size(); int prot; =20 assert_memory_lock(); =20 - if (qemu_host_page_size <=3D TARGET_PAGE_SIZE) { + if (host_page_size <=3D TARGET_PAGE_SIZE) { start =3D address & TARGET_PAGE_MASK; last =3D start + TARGET_PAGE_SIZE - 1; } else { - start =3D address & qemu_host_page_mask; - last =3D start + qemu_host_page_size - 1; + start =3D address & -host_page_size; + last =3D start + host_page_size - 1; } =20 p =3D pageflags_find(start, last); @@ -670,7 +671,7 @@ void page_protect(tb_page_addr_t address) =20 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 =3D pageflags_next(p, start, last)) !=3D NULL) { prot |=3D p->flags; } @@ -678,7 +679,7 @@ void page_protect(tb_page_addr_t address) =20 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 =3D qemu_real_host_page_size(); target_ulong start, len, i; int prot; =20 - if (qemu_host_page_size <=3D TARGET_PAGE_SIZE) { + if (host_page_size <=3D TARGET_PAGE_SIZE) { start =3D address & TARGET_PAGE_MASK; len =3D TARGET_PAGE_SIZE; prot =3D p->flags | PAGE_WRITE; pageflags_set_clear(start, start + len - 1, PAGE_WRITE, 0); current_tb_invalidated =3D tb_invalidate_phys_page_unwind(star= t, pc); } else { - start =3D address & qemu_host_page_mask; - len =3D qemu_host_page_size; + start =3D address & -host_page_size; + len =3D host_page_size; prot =3D 0; =20 for (i =3D 0; i < len; i +=3D TARGET_PAGE_SIZE) { --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535313; cv=none; d=zohomail.com; s=zohoarc; b=RRB6//V+7UhiMq2n9etGv5SwaLW0lYZpuPmYjkt0D+D5RKzkduv1TSBvoBqr2qGRm0hGxgyBOnUkrdHr+67O2rSABGIxb0uLktCDEpogPanX4g4rqo2SqA31CdyiydQViO4wJtYZPHVqusy8HnFqcXdtYCQW/COW26K+U4fIsuQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535313; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ig/BU1p5rBUclrU24B2APEaCZb1m4+3FwcOcSczB0lA=; b=meOQoFy5f7VNhKkTNmle5SOvldnxs9/x0ysoDhrOQPnQaLLpgwrxiFaf1gVclmGFf8XgkmaEItx+jJ69M3rLBFHI/dsSQTxdqx5RhTAo+kICULWZ3oK3Adbl28X+7A+yi5MVpWZtz9sR82Svo4j289wB5CrKm9OzlhjG1Yv/JkU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535313371204.9521111195321; Thu, 31 Aug 2023 19:28:33 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IFaLzWmRWv7Om/dKuPxqaoSASrJBQ+Zkr4UjPiuBx7H/7c1VaKRHifuyB3UBKwZdW1JHt2geQ== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535314018100001 Content-Type: text/plain; charset="utf-8" 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 =3D interp_info.fp_abi; --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535191226107.69931844727341; Thu, 31 Aug 2023 19:26:31 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IHE+LlPemmHaxhE32S2daEbvcy1c+TUwD/IVpzJOKzwSn/TzcAheBrRoWakwfMoYWS1K+pUww== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1693535192004100002 Content-Type: text/plain; charset="utf-8" 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 gues= t_loaddr, =20 /* Add any HI_COMMPAGE not covered by reserved_va. */ if (reserved_va < HI_COMMPAGE) { - ga->bounds[n][0] =3D HI_COMMPAGE & qemu_host_page_mask; + ga->bounds[n][0] =3D HI_COMMPAGE & -qemu_real_host_page_size(); ga->bounds[n][1] =3D HI_COMMPAGE + TARGET_PAGE_SIZE - 1; n++; } @@ -2894,7 +2894,7 @@ void probe_guest_base(const char *image_name, abi_ulo= ng guest_loaddr, abi_ulong guest_hiaddr) { /* In order to use host shmat, we must be able to honor SHMLBA. */ - uintptr_t align =3D MAX(SHMLBA, qemu_host_page_size); + uintptr_t align =3D MAX(SHMLBA, TARGET_PAGE_SIZE); =20 /* Sanity check the guest binary. */ if (reserved_va) { --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535100; cv=none; d=zohomail.com; s=zohoarc; b=Rkt/DdGTr7as7xpb9beBQbiaR4IaiI2v7udwDkX+jnNwxgiD/haiZ66WmmR2Q5FL5TvCY8kYFGWGA50tYwisO3fpaj6Fo7XcfbrPbzmffZyrINy8XT1Yc96R5FyNTjvtZ8vvi2fpG3vRkC5oPSPEkQfV9kAJVKZ9z6IQ90bBBHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535100; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l1Ia6H4r6/UDLfCIgaKhnJIkJDHurCCHa2efkMKJruA=; b=ArTLR55MW4r2WvS4/yn/VEXlxVrfHyH9rwZLIoD12b1s7mLhKLr9VBO5uiWICKmQDgUoe+fas2SCi8PV0VTWkf4fwZevVWuwBt83jQdJbcCDcbVWQFYttr4AFC99/PR7hgBtCZJkTaIlHFGvjk3j8+sXkQUi+5pJoKeQ8MygDkk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535100217444.29816309370847; Thu, 31 Aug 2023 19:25:00 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IHEALxxBg6d86WOmSKU1byXjrg4JPQqlT9FMnuoRk3lgRk7KjWBr+fjPJE08JZd3pMSH9z5cA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535102343100003 Content-Type: text/plain; charset="utf-8" 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) !=3D 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); --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535136; cv=none; d=zohomail.com; s=zohoarc; b=ZrVS4Kw05HRXg2rZvENoZN4vI4HeON+hZ+JEzsF7ipaOmwYWKSk6AmthA/Dzpagc1sWPXR0rfbkhhS+qK1+B7O5iJp9pxrfZRBP+8f6M11R5rWdboU3Q+Py5oTPT2Qaejl1uvXgtdFsUJESyJ1CbWxTkvthb5kfQzmdAuYMZ6+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535136; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3P9EWl1tJVitUp2HhYjFwCQR4+GDFyi+Ud4oCYb+o1w=; b=I+gYhih4lIJbC+UjxBqZRz3U4nWdiyteol2fCeE4s4KZpIfg3fa4LfgnSdmdFR3PgMTFE9Ptd137il/6WYRW36HcyjkFKJI7lPgMIiMhpCmUA3/JHib888IkN8DOWJttHiDVKhfFLLfD1ka7XPTv0Y0TPwsj+Bb2gZxTPM/vkic= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535136211175.2835769156544; Thu, 31 Aug 2023 19:25:36 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IEVEcEjOMSFnapwxf/hgd2mTaEqdPYEiqRuqyrWmRx8i4VEPp95mrT44AgBlzUuSJ+lKLgenQ== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535137050100001 Content-Type: text/plain; charset="utf-8" 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_reg= s *regs, =20 static bool init_guest_commpage(void) { - void *want =3D g2h_untagged(LO_COMMPAGE); - void *addr =3D 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 =3D qemu_real_host_page_size(); + void *want, *addr; =20 - if (addr =3D=3D MAP_FAILED) { - perror("Allocating guest commpage"); - exit(EXIT_FAILURE); - } - if (addr !=3D want) { - return false; + want =3D g2h_untagged(LO_COMMPAGE); + addr =3D mmap(want, host_page_size, PROT_NONE, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED_NOREPLACE, -1,= 0); + if (addr =3D=3D MAP_FAILED) { + perror("Allocating guest commpage"); + exit(EXIT_FAILURE); + } + if (addr !=3D want) { + return false; + } } =20 /* --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535084; cv=none; d=zohomail.com; s=zohoarc; b=BJedmQO4sVck6TN20pPdWMQvhaMjqe3AKd1FpMJjbAqCzAWb5G4vBZqchtS52wbR2dW9s7bnRL0RHUalYQnezN3t8USacSIRUrSmuGu3ttaqPmPzaEbQ/ipbCEwRhdYMqOo5pEyDfJ/c9TC/XP1vHTgy6wedULnzu+VSg9TZ+lE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535084; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nu15p4NzoIMDD0853qBh0z3WcT+BzXtXp1Q+7rXZXJc=; b=dsLS+wbtSxYwygTbDJFLhajLP7Gbwf33HAI6cCMSGhZvwqxh7wpmZ/DRctgL2QA0TbNSwFzXhaQVCVFkr6o0vjey4fqGPqhWxFgYKPqf6JbY3QjJNcNSY7tsIVR8Vwaje7HtYzYu/5y/DWFi+g/6x74DRi1TULIqw9bukC7I228= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535084139491.1682378140338; Thu, 31 Aug 2023 19:24:44 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IEPmheF9MfC0qMGWLitBk3CRaLMh4KHpjQBCvPh9/r/outUT/f4y93ExGoNRG/NKG/Y6T1A6Q== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535085190100003 Content-Type: text/plain; charset="utf-8" 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 */ }; =20 - void *want =3D g2h_untagged(LO_COMMPAGE & -qemu_host_page_size); - void *addr =3D mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + int host_page_size =3D qemu_real_host_page_size(); + void *want, *addr; =20 + want =3D g2h_untagged(LO_COMMPAGE & -host_page_size); + addr =3D mmap(want, host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | + (reserved_va ? MAP_FIXED : MAP_FIXED_NOREPLACE), + -1, 0); if (addr =3D=3D MAP_FAILED) { perror("Allocating guest commpage"); exit(EXIT_FAILURE); @@ -1367,9 +1371,9 @@ static bool init_guest_commpage(void) return false; } =20 - memcpy(addr, kuser_page, sizeof(kuser_page)); + memcpy(g2h_untagged(LO_COMMPAGE), kuser_page, sizeof(kuser_page)); =20 - if (mprotect(addr, qemu_host_page_size, PROT_READ)) { + if (mprotect(addr, host_page_size, PROT_READ)) { perror("Protecting guest commpage"); exit(EXIT_FAILURE); } --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535272; cv=none; d=zohomail.com; s=zohoarc; b=NlEhNQsnrG3YwvZjt506xmlfqHNzHNL2eb6TMcgJuXDClGPD8lDUgD2neN4dRYMeo0oA+dlyfnf94tqlISEWSXZHQg8yKCza36eKyivO/mfd3eWg4lmRDYU98tmzXRFGkIqjFbPUsjICPqmEBavjAK0dImno/4H3ham8RSGUGoE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535272; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NDM65t73LpAV7FxjJeTkMdvecmbGc18VHwUu48Q6+VY=; b=nr3aWqFQTIAJFbJO1lVoLwkaQKHRHLrjPPYgih5hcyQT32hlr/QiZDNU/uujXSeGpbYoc+siSC26ybStw0fL1dleKYL5EJqqxRyOZYt4BX1N74I3lPdpB1rbMw8Tc9iJeU4U4kubQbKI3mBJDxmuJAnw6VUkE1q6KEYFbVBJaXE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169353527206544.86109688348563; Thu, 31 Aug 2023 19:27:52 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IFqBUNjB+MAj0nYewPOfITbqmjroSiF9X/fm1P4yXg3bknp7m/NAndyLif+uIXF65lUb7UkUw== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535272758100005 Content-Type: text/plain; charset="utf-8" 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 =3D ARM_CPU(thread_cpu); + int host_page_size =3D qemu_real_host_page_size(); abi_ptr commpage; void *want; void *addr; @@ -462,10 +463,12 @@ static bool init_guest_commpage(void) return true; } =20 - commpage =3D HI_COMMPAGE & -qemu_host_page_size; + commpage =3D HI_COMMPAGE & -host_page_size; want =3D g2h_untagged(commpage); - addr =3D mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + addr =3D mmap(want, host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | + (commpage < reserved_va ? MAP_FIXED : MAP_FIXED_NOREPLACE), + -1, 0); =20 if (addr =3D=3D 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)); =20 - if (mprotect(addr, qemu_host_page_size, PROT_READ)) { + if (mprotect(addr, host_page_size, PROT_READ)) { perror("Protecting guest commpage"); exit(EXIT_FAILURE); } =20 - 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; } --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535124066112.10516192538671; Thu, 31 Aug 2023 19:25:24 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IGDBhDzYA97npnCzQ2UlvnjxXlVOimX+iObGDaqRKWLcrCi5jXVx4Y3pAxxe8f6cbBIpfTc9w== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1693535193907100009 Content-Type: text/plain; charset="utf-8" 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 =3D 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, i= nt target_prot) } =20 last =3D start + len - 1; - host_start =3D start & qemu_host_page_mask; + host_start =3D start & -host_page_size; host_last =3D HOST_PAGE_ALIGN(last) - 1; nranges =3D 0; =20 mmap_lock(); =20 - 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 =3D target_prot; for (abi_ulong a =3D host_start; a < start; a +=3D TARGET_PAGE_SIZ= E) { @@ -161,7 +162,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int= target_prot) prot1 |=3D page_get_flags(a + 1); } starts[nranges] =3D host_start; - lens[nranges] =3D qemu_host_page_size; + lens[nranges] =3D host_page_size; prots[nranges] =3D prot1; nranges++; } else { @@ -174,10 +175,10 @@ int target_mprotect(abi_ulong start, abi_ulong len, i= nt target_prot) /* If the resulting sum differs, create a new range. */ if (prot1 !=3D target_prot) { starts[nranges] =3D host_start; - lens[nranges] =3D qemu_host_page_size; + lens[nranges] =3D host_page_size; prots[nranges] =3D prot1; nranges++; - host_start +=3D qemu_host_page_size; + host_start +=3D host_page_size; } } =20 @@ -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 !=3D target_prot) { - host_last -=3D qemu_host_page_size; + host_last -=3D host_page_size; starts[nranges] =3D host_last + 1; - lens[nranges] =3D qemu_host_page_size; + lens[nranges] =3D host_page_size; prots[nranges] =3D 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 las= t, int prot, int flags, int fd, off_t offset) { + int host_page_size =3D 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 s= tart, abi_ulong last, return false; } =20 - real_last =3D real_start + qemu_host_page_size - 1; + real_last =3D real_start + host_page_size - 1; host_start =3D g2h_untagged(real_start); =20 /* 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 =3D mmap(host_start, qemu_host_page_size, + void *p =3D mmap(host_start, host_page_size, target_to_host_prot(prot), flags | MAP_ANONYMOUS, -1, 0); if (p !=3D host_start) { if (p !=3D MAP_FAILED) { - munmap(p, qemu_host_page_size); + munmap(p, host_page_size); errno =3D EEXIST; } return false; @@ -280,7 +282,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong s= tart, abi_ulong last, /* Adjust protection to be able to write. */ if (!(host_prot_old & PROT_WRITE)) { host_prot_old |=3D PROT_WRITE; - mprotect(host_start, qemu_host_page_size, host_prot_old); + mprotect(host_start, host_page_size, host_prot_old); } =20 /* Read or zero the new guest pages. */ @@ -294,7 +296,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong s= tart, abi_ulong last, =20 /* Put final protection */ if (host_prot_new !=3D 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 sta= rt, abi_ulong size, */ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) { + int host_page_size =3D qemu_real_host_page_size(); void *ptr, *prev; abi_ulong addr; int wrapped, repeat; =20 - align =3D MAX(align, qemu_host_page_size); + align =3D MAX(align, host_page_size); =20 /* If 'start' =3D=3D 0, then a default start address is used. */ if (start =3D=3D 0) { start =3D mmap_next_start; } else { - start &=3D qemu_host_page_mask; + start &=3D -host_page_size; } start =3D ROUND_UP(start, align); =20 @@ -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 =3D qemu_real_host_page_size(); abi_ulong ret, last, real_start, real_last, retaddr, host_len; abi_ulong passthrough_start =3D -1, passthrough_last =3D 0; int page_flags; @@ -493,8 +497,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, } } =20 - real_start =3D start & qemu_host_page_mask; - host_offset =3D offset & qemu_host_page_mask; + real_start =3D start & -host_page_size; + host_offset =3D offset & -host_page_size; =20 /* * 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, in= t 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; =20 if (fstat(fd, &sb) =3D=3D -1) { @@ -551,11 +554,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, i= nt target_prot, host_len =3D HOST_PAGE_ALIGN(host_len); host_prot =3D target_to_host_prot(target_prot); =20 - /* - * 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 =3D mmap(g2h_untagged(start), host_len, host_prot, flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); if (p =3D=3D MAP_FAILED) { @@ -621,7 +620,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, * aligned, so we read it */ if (!(flags & MAP_ANONYMOUS) && - (offset & ~qemu_host_page_mask) !=3D (start & ~qemu_host_page_= mask)) { + (offset & (host_page_size - 1)) !=3D (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, in= t target_prot, =20 /* handle the start of the mapping */ if (start > real_start) { - if (real_last =3D=3D real_start + qemu_host_page_size - 1) { + if (real_last =3D=3D 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 +=3D qemu_host_page_size; + real_start +=3D host_page_size; } /* handle the end of the mapping */ if (last < real_last) { - abi_ulong real_page =3D real_last - qemu_host_page_size + 1; + abi_ulong real_page =3D 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 -=3D qemu_host_page_size; + real_last -=3D host_page_size; } =20 /* map the middle (easier) */ @@ -739,6 +738,7 @@ fail: =20 static void mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) { + int host_page_size =3D 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; =20 last =3D start + len - 1; - real_start =3D start & qemu_host_page_mask; + real_start =3D start & -host_page_size; real_last =3D HOST_PAGE_ALIGN(last) - 1; =20 /* @@ -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 =3D 0; for (a =3D real_start; a < start; a +=3D TARGET_PAGE_SIZE) { prot |=3D page_get_flags(a); @@ -773,14 +773,14 @@ static void mmap_reserve_or_unmap(abi_ulong start, ab= i_ulong len) prot |=3D page_get_flags(a); } if (prot !=3D 0) { - real_start +=3D qemu_host_page_size; + real_start +=3D host_page_size; } =20 for (prot =3D 0, a =3D last; a < real_last; a +=3D TARGET_PAGE_SIZ= E) { prot |=3D page_get_flags(a + 1); } if (prot !=3D 0) { - real_last -=3D qemu_host_page_size; + real_last -=3D host_page_size; } =20 if (real_last < real_start) { --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535220; cv=none; d=zohomail.com; s=zohoarc; b=RHZiDnyT+sXc2GuE56Kg0e36tN8mWB/PJ5nU/1Vrmqlt9oToRGV7cFnMUGW3d+pkm19ZanddeBTE7v3TiqRS5qjJFCY/6TiLzoIPJZe/PtEiI2eFH0A1550AioCfXIfIFwnvZkQ7iadS/TbhBQDOAWg5j6tBKZKQGP6SiZytZOg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535220; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LVk5X9WdvzLtlHCovbmOH3Icf/xYwVyrtvZHkdMNBJ8=; b=DLloDZkYaJ2DB+qGX77BgV7wrDdpCp9X4dgS67TSeEVNfeXadLsMrlR/L8hajImryW/QQOJU7+Tt+VgiiUvo0ltxPjYCIp8MbuvLY8atIJzpCRUb1aH4fpC32veBYEjiip9/MIeiEFu6U0/y0FFv4mcLNAq05x97fcpf0jT2i28= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169353522088368.24777213449943; Thu, 31 Aug 2023 19:27:00 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IFzsTkyqQdHHR1HRsjjj+aR096K+pxKwNM5L3t7aKsjAKwpXfJrrUZW6gj6p4NDAMF7nk3QBQ== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535222989100003 We already have qemu_real_host_page_size() in a local variable. Reviewed-by: Philippe Mathieu-Daud=C3=A9 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, in= t target_prot, * the hosts real pagesize. Additional anonymous maps * will be created beyond EOF. */ - len =3D REAL_HOST_PAGE_ALIGN(sb.st_size - offset); + len =3D ROUND_UP(sb.st_size - offset, host_page_size); } } =20 --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535264; cv=none; d=zohomail.com; s=zohoarc; b=RvmW/SQPerTvqdo4/NlILriLhB6LGGIxod1s17/5veIa27DtS6CO0muGKRGIN5eE49HCEbskgriS2jxBNC+6Whv/oCe7f1oDz/3VJFvpBW3n19HQmiR99pQTUK1lFtKLGsd6JbuOCrrfwffRVmuV5xUPzLbeF8lKYwb//YCuo8M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535264; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zm6LGbzRYY77HgezAnXq5Cmr5DPYLmRbQvieaAAbplU=; b=NKeGuQHN2/xtMVtOGiYQR4eR/uyDEOawQDb5moI2E9fOTlkkRBXHGtW2LS/Ej3X6HnKe1I+AKnchhOOdnM2apBHjsva+nZOp0LUBJgSkhhzXw/QslJv9FWvV4MWi9PSzkV8BTh7LNstiED1zVBFba9nAywkDtp2eyUsRT2wjbxo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535264178996.6088126040387; Thu, 31 Aug 2023 19:27:44 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IGG+Pig2ODe/ASGgMrvfI+BW6MV8dg7uy6erSqjR8SCMXBMftombdzVhktzeY3C2zfFdAs36A== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535265038100003 Content-Type: text/plain; charset="utf-8" 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) =20 last =3D start + len - 1; host_start =3D start & -host_page_size; - host_last =3D HOST_PAGE_ALIGN(last) - 1; + host_last =3D ROUND_UP(last, host_page_size) - 1; nranges =3D 0; =20 mmap_lock(); @@ -345,8 +345,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size= , abi_ulong align) start &=3D -host_page_size; } start =3D ROUND_UP(start, align); - - size =3D HOST_PAGE_ALIGN(size); + size =3D ROUND_UP(size, host_page_size); =20 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, in= t target_prot, */ if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { host_len =3D len + offset - host_offset; - host_len =3D HOST_PAGE_ALIGN(host_len); + host_len =3D ROUND_UP(host_len, host_page_size); start =3D mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); if (start =3D=3D (abi_ulong)-1) { errno =3D ENOMEM; @@ -551,7 +550,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, void *p; =20 host_len =3D len + offset - host_offset; - host_len =3D HOST_PAGE_ALIGN(host_len); + host_len =3D ROUND_UP(host_len, host_page_size); host_prot =3D target_to_host_prot(target_prot); =20 /* Note: we prefer to control the mapping address. */ @@ -581,7 +580,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, goto fail; } last =3D start + len - 1; - real_last =3D HOST_PAGE_ALIGN(last) - 1; + real_last =3D ROUND_UP(last, host_page_size) - 1; =20 /* * 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) =20 last =3D start + len - 1; real_start =3D start & -host_page_size; - real_last =3D HOST_PAGE_ALIGN(last) - 1; + real_last =3D ROUND_UP(last, host_page_size) - 1; =20 /* * If guest pages remain on the first or last host pages, --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535232; cv=none; d=zohomail.com; s=zohoarc; b=W6X3+fZfWEyEzNNayqostmbZt9lWECUgsBzpMFwYnf7f9aTtd00E4sBKWxlqkdj2FUJ1uCcobmPlPeWGw87E36VLcQm9dS2MU52cPA/Ks0bY6m4SjOvcV9zi9O9KuieZa5H1F4Eew1RJRFf/VpeWUS1sp3ynoxYhORm/qAe8NxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535232; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aNsGM1lrXvwjZfK8fzxAwlxZ3vZk+R9BD/kfTxJ1kzo=; b=We/h2tY1rqMAxqY6FBeFz7dTNf2rofoZ2MOTSY1P7rDUv1F+SUfWizPM3R3+swuGWbFOWE6iu1gTtyJi5m5umo8dxIlRgswYletl+zRLR6u46hxlvDfUH9tAzIAd/aLiW62fvjdzJPhlLyISC1k8EAGk/YgaEKsEkHR0p0zTV7Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535232522499.9931044516826; Thu, 31 Aug 2023 19:27:12 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IGyWk384MZ2BoGIFBsL4E/bg1M5GvVMoZex2JuiQmQsia9Pd2oJ8SD0UjjKYHJPQsAoSn94fA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535233116100001 Content-Type: text/plain; charset="utf-8" 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 =3D opaque; RAMBlock *block; - int ret; + int ret, max_hg_page_size; =20 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 =3D f; =20 + /* + * ??? Mirrors the previous use of qemu_host_page_size below, + * but is this really what was intended for the migration? + */ + max_hg_page_size =3D 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->idst= r)); qemu_put_be64(f, block->used_length); - if (migrate_postcopy_ram() && block->page_size !=3D - qemu_host_page_size) { + if (migrate_postcopy_ram() && + block->page_size !=3D 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 =3D migration_incoming_get_current(); int flags =3D 0, ret =3D 0, invalid_flags =3D 0, len =3D 0, i =3D 0; + int max_hg_page_size; + /* ADVISE is earlier, it shows the source has the postcopy capability = on */ bool postcopy_advised =3D migration_incoming_postcopy_advised(); if (!migrate_compress()) { invalid_flags |=3D RAM_SAVE_FLAG_COMPRESS_PAGE; } =20 + /* + * ??? Mirrors the previous use of qemu_host_page_size below, + * but is this really what was intended for the migration? + */ + max_hg_page_size =3D 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 =3D NULL, *host_bak =3D 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 !=3D qemu_host_page_size) { + block->page_size !=3D max_hg_page_size) { uint64_t remote_page_size =3D qemu_get_be64(f); if (remote_page_size !=3D block->page_size) { error_report("Mismatched RAM page size %s " --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535052; cv=none; d=zohomail.com; s=zohoarc; b=LtCk54cwxDi3idnGh+/AHKVto5mZDPmR1bB88d0WR9jg3yQhjN4zlEuZFfpCWYYwUN0Qg2LhzZuKCcyCwe/VwZiiG6ns2OKE/j7ic++EEVgMMDWFwGnxG3eGdh321oxy2Kxtiz+MDEu5gD/uXzRYlTue6xvZ6jF02Up9SeidlYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535052; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jBDFYDN4txkYXCl4MK4JvDX5trolAszB5+TZawsyMV0=; b=U8TPf+FVRNGA+LwfV1B0LH2WP8TA7MmK+rGUgbmNpA2lxikaC1xD5KzZ8OExMjO1FVpDhfCBy6dtmHxG5EfGzk6Q+oHrRGpFiJolmOAVtWWwF8WxaxaIV8SkdMVupYP46KeiSbYbLpdqhzEewy+zmcWL3KS4W52qbB3xjsT+1gU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535052342976.7056462168598; Thu, 31 Aug 2023 19:24:12 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IH6iwMuURxNzBZkaYXQO9hbFaUxfXYntU6ovCngMyrsofTVshvFFLJ9CkTY3qij/dq3qMUr/A== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535052701100001 Content-Type: text/plain; charset="utf-8" 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 =3D qemu_memalign(qemu_real_host_page_size(), - HOST_PAGE_ALIGN(TPM_PPI_ADDR_SIZE)); + tpmppi->buf =3D 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)); --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535312; cv=none; d=zohomail.com; s=zohoarc; b=TEQXaSG+EaDvkpSj9851PtdigRBhRBh6kW9IW/SMENxAAQF/ZzhfB4/H4lH7H+Vckt8yMeIjXjNfyWBzc/5KgFx4gTvSQEhwnuvwgnGk8Toc98pi4w7VAeDCXd5W3z8mQTXLznczyfGbCjbkUT4x6MAiGV/qw4jtGT+oHbpPvQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535312; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RG0I5fdtJkgseX4CxGvr61fKZ2D6UQ2yfGBN0aVfn4c=; b=eT6geNOgutq7fOXwB3zUc02PF/mZ/PQuPFtUzHvqcDVepF8TZPB0YKgbF1Qac5P020lJV+1aucpLEokCXnV228ZNtUsS8AEf12g9GB3NO8kafOiPwnduFI9MtPN3sgC/FCYwT+/D9Coy3UOMP5eKJ63mLTrY+poI96RoqZCe0/g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535312885762.3945052009418; Thu, 31 Aug 2023 19:28:32 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IG25jrrzI1Ttgu16lzhCPYyM3NpDIaki3TDguCUFDAjAxmpdV5vLR97xZ2cPHQ7MScRx4DsNA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535314848100004 Content-Type: text/plain; charset="utf-8" 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 st= art, size_t length) * fallocate works on hugepages and shmem * shared anonymous memory requires madvise REMOVE */ - need_madvise =3D (rb->page_size =3D=3D qemu_host_page_size); + need_madvise =3D (rb->page_size =3D=3D qemu_real_host_page_size()); need_fallocate =3D rb->fd !=3D -1; if (need_fallocate) { /* For a file, this causes the area of the file to be zero'd --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535301; cv=none; d=zohomail.com; s=zohoarc; b=l5Nm0q30YKn4dsygxrKTVCxIIDdGBkN/AD3pdQ0uoxq+NZF1dZHFZY4Vadl4+zAzg9PGMXHuQXjHMKVfHeg9K0eexRBpFQBZlrcG4xklW+nZpCzXDyn1TqcY0hsioWMiKNR9WfaCi03sUkIMS5X2IpcuLseQDAPYvBkppb0GOyE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535301; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oX0Wvey1e2J0VCCaIBZPR7REasOlAnSls/c5wuVfncQ=; b=J+juGqBJC7CbmOfUd/jJ3hTS9yZWtvvSLLwk5uhaEPXGwWEIFzV0DoZsSgEschByiZFVn2uqdch/ZcVAK6/IEXPJ1SDrMNQis1mZ6guPEkIe7R9o9bk0k461Q8SPNsY8EDhxEuGwdZ1scp0aHlgOscjYtVPoaaDUMU6qk8eu5VA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535301890926.4371963236557; Thu, 31 Aug 2023 19:28:21 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IH4R4nsngdbLi41OHlYq9mgFXST44EAWvjA4AFLka3dF+kFymEamPhxMlUm4ePtFmBI/PBcKA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535302608100003 Content-Type: text/plain; charset="utf-8" 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 newsi= ze, Error **errp) =20 assert(block); =20 - newsize =3D HOST_PAGE_ALIGN(newsize); + newsize =3D TARGET_PAGE_ALIGN(newsize); + newsize =3D REAL_HOST_PAGE_ALIGN(newsize); =20 if (block->used_length =3D=3D newsize) { /* @@ -1897,7 +1898,9 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, Mem= oryRegion *mr, return NULL; } =20 - size =3D HOST_PAGE_ALIGN(size); + size =3D TARGET_PAGE_ALIGN(size); + size =3D REAL_HOST_PAGE_ALIGN(size); + file_size =3D 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 =3D NULL; + int align; =20 assert((ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC | RAM_NORESERVE)) =3D=3D 0); assert(!host ^ (ram_flags & RAM_PREALLOC)); =20 - size =3D HOST_PAGE_ALIGN(size); - max_size =3D HOST_PAGE_ALIGN(max_size); + align =3D qemu_real_host_page_size(); + align =3D MAX(align, TARGET_PAGE_SIZE); + size =3D ROUND_UP(size, align); + max_size =3D ROUND_UP(max_size, align); + new_block =3D g_malloc0(sizeof(*new_block)); new_block->mr =3D mr; new_block->resized =3D resized; --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535301; cv=none; d=zohomail.com; s=zohoarc; b=W8NFtcU9SYf62N5LZlMi1gOnS5H+ATtD+R3sqzJXfMkMn5UBqQkP118HHQ10a1+dMSn1EPCzOqNx1UK0uKIF8LXkUlxLBpptW9JWa/hAatVzdfy4MZijsUiJob5MC+pYnlusxjvRTm+uU2JgSNmDBp7nH8hxfMsMQg9AMU1FkQU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535301; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LMSfIZM5KDQOW8rzGrPmwonqS4UNbZW6sqmCOtQy3AM=; b=fLOL5npXbp5nlk9ePGJXMYjgZsVLIMlEDDUM+nJMAzUuLeRsD68BnPLps+co0xfOUlqgbFVwGIaEQhOm3IcQe7dzKrd2SrZ2QCX9YS0mJJuC0lsRbHYoI3/eZzXZ+nQaHmCFSBatb5EqhZAyZuTfcPzxzhfjqeox6hhNRiK69kU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535301828719.4311804711939; Thu, 31 Aug 2023 19:28:21 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IH0N69Ag1dwmMoj4SyP8SvuFPxoeqTtUQhQnl9WEsCK1HEZ3Cs2KVyobtfYFf5NYVHnCZClXw== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535302603100002 Content-Type: text/plain; charset="utf-8" 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 =3D parse_cpu_option(cpu_model); =20 - /* init tcg before creating CPUs and to get qemu_host_page_size */ + /* init tcg before creating CPUs */ { AccelState *accel =3D current_accel(); AccelClass *ac =3D ACCEL_GET_CLASS(accel); @@ -806,8 +806,10 @@ int main(int argc, char **argv, char **envp) */ max_reserved_va =3D MAX_RESERVED_VA(cpu); if (reserved_va !=3D 0) { - if ((reserved_va + 1) % qemu_host_page_size) { - char *s =3D size_to_str(qemu_host_page_size); + int host_page_size =3D qemu_real_host_page_size(); + + if ((reserved_va + 1) % host_page_size) { + char *s =3D 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 =3D=3D 0) { - mmap_min_addr =3D qemu_host_page_size; + mmap_min_addr =3D qemu_real_host_page_size(); qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=3D0x%lx (fallback)\n", mmap_min_addr); --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535096; cv=none; d=zohomail.com; s=zohoarc; b=OaL4WiXnH82c5vm7scyg4S5MSzP8GtZOpuHlXbbMWRq/YWAoGOeOEXVHR1IHrj8nT45cQgJ22sHNQ6/FVzh53MNevUTkqMYav3dP1ytvrJkGg737hLcvvFh6cNj4K/ongRnoYf1woE+9izMIfQQ4c5/8oT5U7UOoPWZEjBaD1Ww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535096; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UmUiHb3W9eyE4ZQAOrL3J/DCoQ07HdYWjlQFvdkx5l8=; b=Ye8MFBlsQ5IRUvg0jmslJa55ONqDlLmekMPECv0l290Vzvp6eAxeC/vnaAaw1Uy6K3nFb5pBCtDNqgaCESDcxCMULHuqzDrH8cKoIsAiU724tXTY1rXHw9llxTZFPlAG8cSSH3sznbZLjWc7n45Ap5HIPcoEDUcAYyUcIQUEe3s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535096170296.32824094792136; Thu, 31 Aug 2023 19:24:56 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IFiW8c+fgaWOOT6aOCkF+MyhFlsTWNpRqkgLQ53Si3dbknBJyLgINuaymjQl+YekS5cD4ThsQ== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535160757100002 All "goto fail" may be transformed to "return -1". Reviewed-by: Philippe Mathieu-Daud=C3=A9 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) } } =20 -/* 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 =3D 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; =20 - mmap_lock(); - trace_target_mmap(start, len, target_prot, flags, fd, offset); - if (!len) { errno =3D EINVAL; - goto fail; + return -1; } =20 page_flags =3D validate_prot_to_pageflags(target_prot); if (!page_flags) { errno =3D EINVAL; - goto fail; + return -1; } =20 /* Also check for overflows... */ len =3D TARGET_PAGE_ALIGN(len); if (!len) { errno =3D ENOMEM; - goto fail; + return -1; } =20 if (offset & ~TARGET_PAGE_MASK) { errno =3D EINVAL; - goto fail; + return -1; } =20 /* @@ -509,7 +506,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, start =3D mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); if (start =3D=3D (abi_ulong)-1) { errno =3D ENOMEM; - goto fail; + return -1; } } =20 @@ -530,7 +527,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, struct stat sb; =20 if (fstat(fd, &sb) =3D=3D -1) { - goto fail; + return -1; } =20 /* Are we trying to create a map beyond EOF?. */ @@ -557,7 +554,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, p =3D mmap(g2h_untagged(start), host_len, host_prot, flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); if (p =3D=3D MAP_FAILED) { - goto fail; + return -1; } /* update start so that it points to the file position at 'offset'= */ host_start =3D (uintptr_t)p; @@ -566,7 +563,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, flags | MAP_FIXED, fd, host_offset); if (p =3D=3D MAP_FAILED) { munmap(g2h_untagged(start), host_len); - goto fail; + return -1; } host_start +=3D offset - host_offset; } @@ -577,7 +574,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, } else { if (start & ~TARGET_PAGE_MASK) { errno =3D EINVAL; - goto fail; + return -1; } last =3D start + len - 1; real_last =3D 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 =3D ENOMEM; - goto fail; + return -1; } =20 if (flags & MAP_FIXED_NOREPLACE) { /* Validate that the chosen range is empty. */ if (!page_check_range_empty(start, last)) { errno =3D EEXIST; - goto fail; + return -1; } =20 /* @@ -627,17 +624,17 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int target_prot, if ((flags & MAP_TYPE) =3D=3D MAP_SHARED && (target_prot & PROT_WRITE)) { errno =3D EINVAL; - goto fail; + return -1; } retaddr =3D target_mmap(start, len, target_prot | PROT_WRITE, (flags & (MAP_FIXED | MAP_FIXED_NOREPLAC= E)) | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (retaddr =3D=3D -1) { - goto fail; + return -1; } if (pread(fd, g2h_untagged(start), len, offset) =3D=3D -1) { - goto fail; + return -1; } if (!(target_prot & PROT_WRITE)) { ret =3D 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 +=3D host_page_size; } @@ -669,7 +666,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, if (!mmap_frag(real_page, real_page, last, target_prot, flags, fd, offset + real_page - start)) { - goto fail; + return -1; } real_last -=3D host_page_size; } @@ -695,7 +692,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, munmap(p, len1); errno =3D EEXIST; } - goto fail; + return -1; } passthrough_start =3D real_start; passthrough_last =3D 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 =3D target_mmap__locked(start, len, target_prot, flags, fd, offset= ); + mmap_unlock(); - return -1; + return ret; } =20 static void mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535084; cv=none; d=zohomail.com; s=zohoarc; b=PuOsSl620WAGNodVDyC8blNKyQzvYcEkkAwKkAYF2wePimG43uSQF3RHrsYu5psAknG8FkyUSMxEr7l4DJI0Rck8qi7SQPRvcyiDuhm5/pQF4VWL76WvKZpy+zFMmQ8fk2QDYzL2IIhkqS25vgLQCnbHzx7shGUve4ilLQ0j9Rw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535084; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=u/C8gVjHYR4xtzLye5oGAh9WlueBxM9IX1xH8cPHtm8=; b=FYqJ23GAyKKfCkojR1l9X1BqRNm5LM0Dxkcl3Imhv3IQiFlu7B4mLceV6JiRiE0Mrb8fzVIKHn9FMkf3WarpxxRprshp4lTeEMDgGBCwReSVTlqby9Pjeh63vDmOFGBQHyyZkG+SsvuMBlnO7yXyyD69DZMGCialp7Qp259UHwM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535084083933.5347909111915; Thu, 31 Aug 2023 19:24:44 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IGLmCJnQPzWxP+oHw0ACgsYXx8g9ZJTt5Y3jQzKBsuehH0V66W18FG9x3SKj1l5m3uWa3UvfA== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535085232100005 Basic validation of operands does not require the lock. Hoist them from target_mmap__locked back into target_mmap. Reviewed-by: Philippe Mathieu-Daud=C3=A9 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 si= ze, abi_ulong align) } =20 static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, - int target_prot, int flags, + int target_prot, int flags, int page_f= lags, int fd, off_t offset) { int host_page_size =3D qemu_real_host_page_size(); abi_ulong ret, last, real_start, real_last, retaddr, host_len; abi_ulong passthrough_start =3D -1, passthrough_last =3D 0; - int page_flags; off_t host_offset; =20 - if (!len) { - errno =3D EINVAL; - return -1; - } - - page_flags =3D validate_prot_to_pageflags(target_prot); - if (!page_flags) { - errno =3D EINVAL; - return -1; - } - - /* Also check for overflows... */ - len =3D TARGET_PAGE_ALIGN(len); - if (!len) { - errno =3D ENOMEM; - return -1; - } - - if (offset & ~TARGET_PAGE_MASK) { - errno =3D 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 lev= el - * 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 =3D thread_cpu; - if (!(cpu->tcg_cflags & CF_PARALLEL)) { - cpu->tcg_cflags |=3D CF_PARALLEL; - tb_flush(cpu); - } - } - real_start =3D start & -host_page_size; host_offset =3D offset & -host_page_size; =20 @@ -572,23 +534,9 @@ static abi_long target_mmap__locked(abi_ulong start, a= bi_ulong len, passthrough_start =3D start; passthrough_last =3D last; } else { - if (start & ~TARGET_PAGE_MASK) { - errno =3D EINVAL; - return -1; - } last =3D start + len - 1; real_last =3D ROUND_UP(last, host_page_size) - 1; =20 - /* - * 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 correct= ly. - */ - if (last < start || !guest_range_valid_untagged(start, len)) { - errno =3D 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; =20 trace_target_mmap(start, len, target_prot, flags, fd, offset); + + if (!len) { + errno =3D EINVAL; + return -1; + } + + page_flags =3D validate_prot_to_pageflags(target_prot); + if (!page_flags) { + errno =3D EINVAL; + return -1; + } + + /* Also check for overflows... */ + len =3D TARGET_PAGE_ALIGN(len); + if (!len || len !=3D (size_t)len) { + errno =3D ENOMEM; + return -1; + } + + if (offset & ~TARGET_PAGE_MASK) { + errno =3D EINVAL; + return -1; + } + if (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) { + if (start & ~TARGET_PAGE_MASK) { + errno =3D EINVAL; + return -1; + } + if (!guest_range_valid_untagged(start, len)) { + errno =3D ENOMEM; + return -1; + } + } + mmap_lock(); =20 - ret =3D target_mmap__locked(start, len, target_prot, flags, fd, offset= ); + ret =3D target_mmap__locked(start, len, target_prot, flags, + page_flags, fd, offset); =20 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 lev= el + * supported by the host -- anything that requires EXCP_ATOMIC will not + * be atomic with respect to an external process. + */ + if (ret !=3D -1 && (flags & MAP_TYPE) !=3D MAP_PRIVATE) { + CPUState *cpu =3D thread_cpu; + if (!(cpu->tcg_cflags & CF_PARALLEL)) { + cpu->tcg_cflags |=3D CF_PARALLEL; + tb_flush(cpu); + } + } + return ret; } =20 --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535143; cv=none; d=zohomail.com; s=zohoarc; b=J7Ghs74JcS6m4RVKtVyb82gRgIvQ6l1+MUHpb/gt80qBOWcJLpl3bERv2f+Ni14dxmlFv6mwETGTsieuthaee22ks0u55flGm0NW5yzitgGDGEJQhPxDOWHcCBvUgIP6su96KrdYq+bVMr6Qu2cac7z1eYJ3NrDHFyJQp46rIKQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535143; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5Yj/XvFLoTKPoAfaLaRz8qbNSbPbOFb4IFK3vAL5tQg=; b=mdD3jYjbiZ+8cB5T7ECco+MLfZYUxZ8YAq/fzvOkWmJLT5Fgl+QCFwUCBdbCY8tsNBwJS14Jq+V5d3TBhpf69Ck2nHa6ayDdULIGTQVIXCxHHNTpyJJNOJh2VsTRKdsw+iMow+WOmXyV+MwZFrsRoD+NTQuqqPw1LWHPDJ3yAl4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535143842764.0781626110872; Thu, 31 Aug 2023 19:25:43 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IFivOqLxgG2wgBF6HazPlUigFXzNqKNZ93LHedL4X4NiWKBIsM81cy+1GTLLqZ4/P1tYQkTVw== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535202149100001 Content-Type: text/plain; charset="utf-8" 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, ab= i_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, ab= i_ulong len, passthrough_last =3D real_last; } } - the_end1: + the_end: if (flags & MAP_ANONYMOUS) { page_flags |=3D PAGE_ANON; } @@ -663,7 +663,6 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_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 =3D qemu_log_trylock(); --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535123; cv=none; d=zohomail.com; s=zohoarc; b=YXLE7xzwAK9XEnOv1C1JGiEupYmTa3yTNujkXrUvxqznc/HUkBGZVizZJ0/TVgZtJUhvZfaHfDGQf6y9cQRcBdyYBqwKh6vTgFnbQtWivi+vb1yxsBMFXz1tTVTacPWBuz51KKmsZDDJEQvU7f1jZFW7CxxzidRZ6RWVNZO6e38= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535123; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JJ46g3X5MlXZj0BEFn3YDfl7TXV4QZY7r+Hh8MCrB4c=; b=Jl6sOwflM7bNkXmI6HZ7J0XWJVvhYuLevEn0aIqnwdNa6ky2Cx2Hvkp2Yh2i9vTZwlk2tD7ujYYoMbovW+NiOxClTZPxuEwjJysh6OFvoyrSLwWujKus/+9Xy1TLJL9PVCIET5qjEcrQL5IN1wxbVIm0M3z5eBhx6JI6FOZpa+M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535123592916.7632501703848; Thu, 31 Aug 2023 19:25:23 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IHVAu5H+TmcTKD7Tdhgxj9snjB4b+9hQfSl/TEs53x344RsUWJWKEymjMSKd8F/ZoNOO5lHxA== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535186530100001 Use a subroutine instead of a goto within target_mmap__locked. Reviewed-by: Philippe Mathieu-Daud=C3=A9 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 siz= e, abi_ulong align) } } =20 +/* + * 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 |=3D PAGE_ANON; + } + page_flags |=3D 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 =3D 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_f= lags, int fd, off_t offset) @@ -588,7 +624,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, ret =3D target_mprotect(start, len, target_prot); assert(ret =3D=3D 0); } - goto the_end; + return mmap_end(start, last, -1, 0, flags, page_flags); } =20 /* handle the start of the mapping */ @@ -599,7 +635,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_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, a= bi_ulong len, passthrough_last =3D real_last; } } - the_end: - if (flags & MAP_ANONYMOUS) { - page_flags |=3D PAGE_ANON; - } - page_flags |=3D 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 =3D 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); } =20 /* NOTE: all the constants are the HOST ones */ --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535135; cv=none; d=zohomail.com; s=zohoarc; b=BvDe+VHn7QI3LLilTsWK6zvNpVRRQ+3c7Dk9QUbg8Vu89s+afF+OgYpnmm3gpdgXbxqJx685qYnj4CIPmRXy6hzFo0THqJJRN7s6svvpWE89Urro3vm1SHQOyqLzGY9TMLTlvbOgQ2DtdtkLPhioTtBxMru0zXko8UvMm9NZ+n0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535135; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7kaLhwLbHzHqv/PeQXejQChX9nX84J3A2xjA5ly6h/g=; b=a8tpHmkGfsOx841K0nKYUu40ZMpEoEAvk88SomqHuaNn5RD7rUS5idBZPNBLwxDpgrSl6U43QsirceQVAdJunfC3rDppn0MiOg8L1faPS/St7/3woICyoz/pWdP210gd0iPLO4rw9rMOImzTiEba12I+rgFW/DErcXE1wdnacqc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535135498178.15139375714648; Thu, 31 Aug 2023 19:25:35 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IGdlVyKlE7XaWeb9M4/7zqNl1citcveANASsKu1V8aX43SozdZSzMba3yaGlAQkt2vBwclRIA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535197044100013 Content-Type: text/plain; charset="utf-8" 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 =3D offset & -host_page_size; =20 /* - * 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 =3D len + offset - host_offset; - host_len =3D ROUND_UP(host_len, host_page_size); - start =3D mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); + start =3D mmap_find_vma(real_start, host_len, + MAX(host_page_size, TARGET_PAGE_SIZE)); if (start =3D=3D (abi_ulong)-1) { errno =3D ENOMEM; return -1; } + start +=3D offset - host_offset; + flags |=3D MAP_FIXED; } =20 /* --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535078; cv=none; d=zohomail.com; s=zohoarc; b=eJvaLb+YrN4CLv00m9vPTI05x6SMgKyLYzG8i2jpX6dibAA28JIREtlklWiIktEjB3rY1QGmLwMwUN+fkKp0mfsvmYbJDi0XMdNYYLh67AxH7ZU2oy8g6kMdi5JkBBUc2QnQ49VuqvbJ78N2Ly25en6oJKr53mgehy+gc/szuYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535078; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ySu5X2pwP/FjpufFI3frCgcVNyTN0K5y3i0eNXjPfK8=; b=CxiH9DmX0GCEK/umcdfgGFLlPsynMl3XlzUqK4HWD7sgAAFTaTKFFTihbLVsUk5O1lF/DbrePnJFxtralCDx6YjJQB+jQNSzKy93mBa2GSJLPUTjzUFrEfl7IiHWetD68C8nSqxf+b23uw9fLi+4yFRforGh5f4hqUoEzdHcZOQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535078785476.7036601182389; Thu, 31 Aug 2023 19:24:38 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IGXVvO7A5l7O+H9Q5JxJ0xxrdrYwGSNphwUh7aOPhKWAVcOBFXDEFENy2GZ7d9yj7EWiLaArA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535079161100001 Content-Type: text/plain; charset="utf-8" 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 la= st, return start; } =20 +/* + * Special case host page size =3D=3D 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 =3D g2h_untagged(start); + abi_ulong last; + + p =3D mmap(want_p, len, host_prot, flags, fd, offset); + if (p =3D=3D MAP_FAILED) { + return -1; + } + if ((flags & MAP_FIXED_NOREPLACE) && p !=3D want_p) { + errno =3D EEXIST; + return -1; + } + + start =3D h2g(p); + last =3D 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_f= lags, int fd, off_t offset) @@ -490,6 +515,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, abi_ulong ret, last, real_start, real_last, retaddr, host_len; abi_ulong passthrough_start =3D -1, passthrough_last =3D 0; off_t host_offset; + int host_prot; =20 real_start =3D start & -host_page_size; host_offset =3D 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 =3D len + offset - host_offset; - start =3D mmap_find_vma(real_start, host_len, - MAX(host_page_size, TARGET_PAGE_SIZE)); - if (start =3D=3D (abi_ulong)-1) { - errno =3D 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 =3D EEXIST; + return -1; + } + flags =3D (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED; + } else if (!(flags & MAP_FIXED)) { + size_t real_len =3D len + offset - host_offset; + abi_ulong align =3D MAX(host_page_size, TARGET_PAGE_SIZE); + + start =3D mmap_find_vma(real_start, real_len, align); + if (start =3D=3D (abi_ulong)-1) { + errno =3D ENOMEM; + return -1; + } + start +=3D offset - host_offset; + flags |=3D MAP_FIXED; } - start +=3D offset - host_offset; - flags |=3D MAP_FIXED; + } + + host_prot =3D target_to_host_prot(target_prot); + + if (host_page_size =3D=3D TARGET_PAGE_SIZE) { + return mmap_h_eq_g(start, len, host_prot, flags, + page_flags, fd, offset); } =20 /* @@ -543,12 +586,10 @@ static abi_long target_mmap__locked(abi_ulong start, = abi_ulong len, =20 if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { uintptr_t host_start; - int host_prot; void *p; =20 host_len =3D len + offset - host_offset; host_len =3D ROUND_UP(host_len, host_page_size); - host_prot =3D target_to_host_prot(target_prot); =20 /* Note: we prefer to control the mapping address. */ p =3D mmap(g2h_untagged(start), host_len, host_prot, @@ -671,8 +712,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, len1 =3D real_last - real_start + 1; want_p =3D g2h_untagged(real_start); =20 - p =3D mmap(want_p, len1, target_to_host_prot(target_prot), - flags, fd, offset1); + p =3D mmap(want_p, len1, host_prot, flags, fd, offset1); if (p !=3D want_p) { if (p !=3D MAP_FAILED) { munmap(p, len1); --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535069; cv=none; d=zohomail.com; s=zohoarc; b=V5sbZGelsTbjXroMMdDHGUvTtSgW68gSt2rHqyR7LTqRiN5bAcUyTzclypIMSGEDQh4WlnN7gncIZZucEA1LNkjTimFP5uhLvaq920yOn71Gm0bfKSUP0AiG4MxOj7E0WjBv+Ak+QzRZ2GY1rc8sXAc8rsLrCKJidovcKppDeBo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535069; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4bucLpoT0vquWNBuZLTOreK2BOdVySJCazC6PuHo6Rk=; b=P0J3k996K7TanuaabPjWtnEX0A4Xm/vO8qH+pLOpjuP4o3svavC6knwhJRUnk9MzRAkDmEbpNkP981mXC0fYroldVVfUC+BwGUzICP/yBOhJm88Zx58WIARsrRcuadctjxQqpDsgNxpU7NXeXP8sQXGMt079czwQt4pwfMMPp5M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535069701478.42195423826934; Thu, 31 Aug 2023 19:24:29 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IEfkwUIJ0e6utln6TltBctXvjuWP+G4++7ijuq5eHT6br5te+Uedy7taCMwidVBUUYfIBKOuA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535071538100001 Content-Type: text/plain; charset="utf-8" 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_ulon= g len, return mmap_end(start, last, start, last, flags, page_flags); } =20 +/* + * 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 =3D g2h_untagged(start); + off_t fileend_adj =3D 0; + int flags =3D mmap_flags; + abi_ulong last, pass_last; + + if (!(flags & MAP_ANONYMOUS)) { + struct stat sb; + + if (fstat(fd, &sb) =3D=3D -1) { + return -1; + } + if (offset >=3D sb.st_size) { + /* + * The entire map is beyond the end of the file. + * Transform it to an anonymous mapping. + */ + flags |=3D MAP_ANONYMOUS; + fd =3D -1; + offset =3D 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 =3D offset + len - sb.st_size; + } + } + + if (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) { + if (fileend_adj) { + p =3D mmap(want_p, len, host_prot, flags | MAP_ANONYMOUS, -1, = 0); + } else { + p =3D mmap(want_p, len, host_prot, flags, fd, offset); + } + if (p !=3D want_p) { + if (p !=3D MAP_FAILED) { + munmap(p, len); + errno =3D EEXIST; + } + return -1; + } + + if (fileend_adj) { + void *t =3D mmap(p, len - fileend_adj, host_prot, + (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED, + fd, offset); + assert(t !=3D 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 =3D len + TARGET_PAGE_SIZE - host_page_size; + p =3D mmap(want_p, host_len, host_prot, flags | MAP_ANONYMOUS, -1,= 0); + if (p =3D=3D MAP_FAILED) { + return -1; + } + + part_len =3D (uintptr_t)p & (TARGET_PAGE_SIZE - 1); + if (part_len) { + part_len =3D TARGET_PAGE_SIZE - part_len; + munmap(p, part_len); + p +=3D part_len; + host_len -=3D part_len; + } + if (len < host_len) { + munmap(p + len, host_len - len); + } + + if (!(flags & MAP_ANONYMOUS)) { + void *t =3D mmap(p, len - fileend_adj, host_prot, + flags | MAP_FIXED, fd, offset); + assert(t !=3D MAP_FAILED); + } + + start =3D h2g(p); + } + + last =3D start + len - 1; + if (fileend_adj) { + pass_last =3D ROUND_UP(last - fileend_adj, host_page_size) - 1; + } else { + pass_last =3D 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_f= lags, int fd, off_t offset) @@ -551,37 +673,9 @@ static abi_long target_mmap__locked(abi_ulong start, a= bi_ulong len, if (host_page_size =3D=3D 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) =3D=3D -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 =3D 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); } =20 if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535142; cv=none; d=zohomail.com; s=zohoarc; b=WsQN8y7fODRTSX5C6CZcK3jOMBQTm4g/L2VPhn0AGIaOXLOAqcGXEW8lHCSM3g+2KdW6sFypsKUArBWyaLhWLeNbgUT5r8oIpk6x3LTxa5pcz/dyweVPoyz1O+ppqD36+blRg8zB9+TsmEjZCI8yWL5UIYZ4e+3Uc9/XzD0HjWI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535142; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NJQTkGtLKBIQbaCTGpYdZiGcCYcEb9NdqL6VTgxKtpE=; b=UOSkWCFqP7oV30vGH5I/wm8RpEvVHtPfztjTpQNqOAlMX6VIu6NvVq9w6XV+nQUx4xGTAgENftEZKreMysNNP6jm/Erd6aErk+PKzYF+CT2Jnq72lBr1JV1RuHzUM91dCwx7WnT+knlchqvXMue1Hzf/hvZZ0KrWZmphuU4JmUY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535142681612.7805812118909; Thu, 31 Aug 2023 19:25:42 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IE8yxLNRwi/uKzUS1y9gG+l2LMaGb2Lro2xmgBcfu9nBNqfrHwmcn0apPXIYhDVuCGhhXNzIQ== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535199885100001 Content-Type: text/plain; charset="utf-8" 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, in= t target_prot) return ret; } =20 -/* 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 las= t, int prot, int flags, int fd, off_t offset) { @@ -629,19 +638,138 @@ static abi_long mmap_h_lt_g(abi_ulong start, abi_ulo= ng len, int host_prot, return mmap_end(start, last, start, pass_last, mmap_flags, page_flags); } =20 +/* + * 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 =3D g2h_untagged(start); + off_t host_offset =3D offset & -host_page_size; + abi_ulong last, real_start, real_last; + bool misaligned_offset =3D false; + size_t host_len; + + if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { + /* + * Adjust the offset to something representable on the host. + */ + host_len =3D len + offset - host_offset; + p =3D mmap(want_p, host_len, host_prot, flags, fd, host_offset); + if (p =3D=3D MAP_FAILED) { + return -1; + } + + /* Update start to the file position at offset. */ + p +=3D offset - host_offset; + + start =3D h2g(p); + last =3D start + len - 1; + return mmap_end(start, last, start, last, flags, page_flags); + } + + if (!(flags & MAP_ANONYMOUS)) { + misaligned_offset =3D (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) !=3D MAP_PRIVATE) { + errno =3D EINVAL; + return -1; + } + } + + last =3D start + len - 1; + real_start =3D start & -host_page_size; + real_last =3D ROUND_UP(last, host_page_size) - 1; + + /* + * Handle the start and end of the mapping. + */ + if (real_start < start) { + abi_ulong real_page_last =3D real_start + host_page_size - 1; + if (last <=3D 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 =3D real_page_last + 1; + } + + if (last < real_last) { + abi_ulong real_page_start =3D 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 =3D 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 =3D real_last - real_start + 1; + want_p +=3D real_start - start; + + if (flags & MAP_ANONYMOUS) { + p =3D mmap(want_p, host_len, host_prot, flags, -1, 0); + } else if (!misaligned_offset) { + p =3D mmap(want_p, host_len, host_prot, flags, fd, + offset + real_start - start); + } else { + p =3D mmap(want_p, host_len, host_prot | PROT_WRITE, + flags | MAP_ANONYMOUS, -1, 0); + } + if (p !=3D want_p) { + if (p !=3D MAP_FAILED) { + munmap(p, host_len); + errno =3D EEXIST; + } + return -1; + } + + if (misaligned_offset) { + /* TODO: The read could be short. */ + if (pread(fd, p, host_len, offset + real_start - start) !=3D 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_f= lags, int fd, off_t offset) { int host_page_size =3D qemu_real_host_page_size(); - abi_ulong ret, last, real_start, real_last, retaddr, host_len; - abi_ulong passthrough_start =3D -1, passthrough_last =3D 0; - off_t host_offset; int host_prot; =20 - real_start =3D start & -host_page_size; - host_offset =3D 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, ab= i_ulong len, } flags =3D (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED; } else if (!(flags & MAP_FIXED)) { + abi_ulong real_start =3D start & -host_page_size; + off_t host_offset =3D offset & -host_page_size; size_t real_len =3D len + offset - host_offset; abi_ulong align =3D MAX(host_page_size, TARGET_PAGE_SIZE); =20 @@ -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 =3D len + offset - host_offset; - host_len =3D ROUND_UP(host_len, host_page_size); - - /* Note: we prefer to control the mapping address. */ - p =3D mmap(g2h_untagged(start), host_len, host_prot, - flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); - if (p =3D=3D MAP_FAILED) { - return -1; - } - /* update start so that it points to the file position at 'offset'= */ - host_start =3D (uintptr_t)p; - if (!(flags & MAP_ANONYMOUS)) { - p =3D mmap(g2h_untagged(start), len, host_prot, - flags | MAP_FIXED, fd, host_offset); - if (p =3D=3D MAP_FAILED) { - munmap(g2h_untagged(start), host_len); - return -1; - } - host_start +=3D offset - host_offset; - } - start =3D h2g(host_start); - last =3D start + len - 1; - passthrough_start =3D start; - passthrough_last =3D last; } else { - last =3D start + len - 1; - real_last =3D 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 =3D EEXIST; - return -1; - } - - /* - * With reserved_va, the entire address space is mmaped in the - * host to ensure it isn't accidentally used for something els= e. - * 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 overwri= te - * any host address mappings. - */ - if (reserved_va) { - flags =3D (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)) !=3D (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) =3D=3D MAP_SHARED - && (target_prot & PROT_WRITE)) { - errno =3D EINVAL; - return -1; - } - retaddr =3D target_mmap(start, len, target_prot | PROT_WRITE, - (flags & (MAP_FIXED | MAP_FIXED_NOREPLAC= E)) - | MAP_PRIVATE | MAP_ANONYMOUS, - -1, 0); - if (retaddr =3D=3D -1) { - return -1; - } - if (pread(fd, g2h_untagged(start), len, offset) =3D=3D -1) { - return -1; - } - if (!(target_prot & PROT_WRITE)) { - ret =3D target_mprotect(start, len, target_prot); - assert(ret =3D=3D 0); - } - return mmap_end(start, last, -1, 0, flags, page_flags); - } - - /* handle the start of the mapping */ - if (start > real_start) { - if (real_last =3D=3D 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 +=3D host_page_size; - } - /* handle the end of the mapping */ - if (last < real_last) { - abi_ulong real_page =3D 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 -=3D 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 =3D 0; - } else { - offset1 =3D offset + real_start - start; - } - len1 =3D real_last - real_start + 1; - want_p =3D g2h_untagged(real_start); - - p =3D mmap(want_p, len1, host_prot, flags, fd, offset1); - if (p !=3D want_p) { - if (p !=3D MAP_FAILED) { - munmap(p, len1); - errno =3D EEXIST; - } - return -1; - } - passthrough_start =3D real_start; - passthrough_last =3D 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); } =20 /* NOTE: all the constants are the HOST ones */ --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535190; cv=none; d=zohomail.com; s=zohoarc; b=hRcridnY25dOwJrwlhV3YDBO0WqyvhSuUZYYMz9TXemWGPaVeSeatqiIyDmZXUVQHAVItjYmcDw1MBXTSz97QXjpxb5QYX4kTTt4I/XTp0i1R+gjud1cyO6Ckc8nQuaSYSo9JOywmI8zUmkc2PnGjc6DVlr9UObO7hnsZGYBXdQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535190; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JVa+6i7ltaDcVRVgM1SyKlnzNS7CnHg1qkG8lXGAgc8=; b=j3o7efOnCoum69rPpPIGA70uBUvgpij9ksjXxxogWOw46ORj+KgDYhMwEr/PFzliVNAsEv3TSXkjKHRmen9h+BSRmt0qdjVjQ+/TsYcTrHYCr2niUlKMA0XzncCqSdTehTONAQHuIf0H+ngNZa5a6AS1POl3VpIGZ7E6Z/LG/60= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169353519033849.16125459259035; Thu, 31 Aug 2023 19:26:30 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IGZlnZrPr5a85TRvGN35rzyi30YztVOcTHUQKy/DrDd0OYC7pckFeFhlCWJx/BIwj/gwo5yIg== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535192369100006 Content-Type: text/plain; charset="utf-8" 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.tar= get 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) =20 run-test-cmov: test-cmov - -# On Alpha Linux only supports 8k pages -EXTRA_RUNS+=3Drun-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 +=3D sha512-vector =20 TESTS +=3D $(ARM_TESTS) - -# On ARM Linux only supports 4k pages -EXTRA_RUNS+=3Drun-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 =20 -# On parisc Linux supports 4K/16K/64K (but currently only 4k works) -EXTRA_RUNS+=3Drun-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:=3D$(filter-out $(SKIP_I386_TESTS), $(ALL_X86_TESTS)) TESTS=3D$(MULTIARCH_TESTS) $(I386_TESTS) =20 -# On i386 and x86_64 Linux only supports 4k pages (large pages are a diffe= rent hack) -EXTRA_RUNS+=3Drun-test-mmap-4096 - sha512-sse: CFLAGS=3D-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 @@ =20 VPATH +=3D $(SRC_PATH)/tests/tcg/m68k TESTS +=3D trap - -# On m68k Linux supports 4k and 8k pages (but 8k is currently broken) -EXTRA_RUNS+=3Drun-test-mmap-4096 # run-test-mmap-8192 diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Make= file.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 =20 -# 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)) =20 -# 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=3D$(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 (current= ly broken) -EXTRA_RUNS+=3Drun-test-mmap-4096 #run-test-mmap-65536 -else -# On PPC32 Linux supports 4K/16K/64K/256K (but currently only 4k works) -EXTRA_RUNS+=3Drun-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 # =20 -# On sh Linux supports 4k, 8k, 16k and 64k pages (but only 4k currently wo= rks) -EXTRA_RUNS+=3Drun-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+=3Drun-test-mmap-8192 --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535123; cv=none; d=zohomail.com; s=zohoarc; b=SE3G8fAXANUuvI0hXNX3XIu+YyOFRfFz9U9+Lz5uXJ/5vi2OaUqJ1ikXXDu0Yx29PQyUi0VEOSGmGInnqBFK87aPLpo9MXjn2CQxHnp96olmwNXFv/DHYWsT3fTFXQxMvpwoyH72DZfb8YbuMeh8xpxV9h70Am9gHQUVXdIFexQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535123; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NKBqBWVnteg7nBg0Ct8xapNabPHsKvd3tq3kc9va8Z0=; b=SSP3/yXFCxmkNzvMo9WOqvw24LJPHl8+7JbtGnYUcvuzUOnd70C37e5AgQZpQOjRRre6RX/p+CR8J+Ii8fmpsrVfeZbLQzozcd3Fd6o3vhSS8mjT++3KEqwzRu86/DpkQe3ShBB/XYkWzlBfHT49pR+wwtreXk/zzOjCtqddaBM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169353512349234.674499617573815; Thu, 31 Aug 2023 19:25:23 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IGsjQJT8a50FXO5Bp/hsUlLsk/YaYflleoUClMmMUfE6JXxwipWf6ks5i2KgxEtyaZMUkkPmw== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535168080100001 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=C3=A9 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/multiarc= h/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 =3D=3D 0); written =3D write(fd, &c, sizeof(c)); assert(written =3D=3D sizeof(c)); + ret =3D ftruncate(fd, pagesize); + assert(ret =3D=3D 0); page =3D mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE, fd, 0); assert(page !=3D MAP_FAILED); =20 --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535286; cv=none; d=zohomail.com; s=zohoarc; b=WUMeGZj6Zi5i0Gfoh36A4jhMAdpOez16yB4Ylf+IvhSWReMpUiGButvZnbgasSrPsFielyWI5FPZuzgRAwLLZxloaV1yOGekv8PhiyoEWv2iJdXjg+8/RQA2ds0BDovYalrfyx5Bob3KPvxLfu3BVxumleV5YOmdTFoJIN8DHbc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535286; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cWlmLzbT46bw9EM178vXYTWBMPDHKbwER57wNuihdYA=; b=XGy4IrVoem3Wv+fWE3VMCfeIK87CZwJ7xk6+mFz78RK5uw/f28M2GfNdmQEDUuo4nPSiec7Xpi3RncDFEH/PVPrQRsAhW2GiOcc1mmFtp+S+vngM7M8VqdTIMZ5bgl5Q5zzP2oAx4AUCmn4bXxakUskbsb43zv1tV2Cr6egtrp0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535286504626.0355785983863; Thu, 31 Aug 2023 19:28:06 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IG859Fs/jE5/vpB4eHKIt/skavzlIAn8xqAVObcdh/Cu57LGpC9mVQZyhmLkNAJ4vQlVtW5Cg== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535288263100003 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Warner Losh --- 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=3Don`` instead. User-mode emulator command line arguments ----------------------------------------- =20 +``-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) ''''''''''''''''''''''''''' =20 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) =20 -``-p pagesize`` - Act as if the host page size was 'pagesize' bytes - ``-g port`` Wait gdb connection to port =20 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 =3D argv[optind++]; } else if (!strcmp(r, "p")) { - qemu_host_page_size =3D atoi(argv[optind++]); - if (qemu_host_page_size =3D=3D 0 || - (qemu_host_page_size & (qemu_host_page_size - 1)) !=3D 0) { - fprintf(stderr, "page size must be a power of two\n"); + unsigned size, want =3D qemu_real_host_page_size(); + + if (qemu_strtoui(arg, NULL, 10, &size) || size !=3D 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) =20 static void handle_arg_pagesize(const char *arg) { - qemu_host_page_size =3D atoi(arg); - if (qemu_host_page_size =3D=3D 0 || - (qemu_host_page_size & (qemu_host_page_size - 1)) !=3D 0) { - fprintf(stderr, "page size must be a power of two\n"); + unsigned size, want =3D qemu_real_host_page_size(); + + if (qemu_strtoui(arg, NULL, 10, &size) || size !=3D 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[] =3D { {"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"}, --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535180; cv=none; d=zohomail.com; s=zohoarc; b=cioGhxNDePUejzG7JIIAWfCjaSI44pEBYDDuDmFmFFIyFj2nySKGGxQ+AoLiDgbt4CAw/R+w9ECbUYTmdyUeqyrGq5ycW2/rISFX686N/8RA7gteUyvjR5ZbKL7uZoKKi1X/CBHhm/OJK4/TdD/EMBPfgou54YYxgN6nvUf4HMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535180; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g3/iatjXff6UUdz2cl7k/bF/yMUs8bwvdLM3Z+AtKOI=; b=OqkzuWW3xnJaWswEZz9s0es0Agr0zZzqxe5MgtFTXeNbOf0ZtsD7iLxD+hEYfG2qaI2KqheWFQaGkUOvUy34XPWd53bGHnN1ckYhBRAphKEcezkNx6r0MbVNi4m8+W+lBzEHJiZOQtUm1A2T8HXJ8ejsFDh6Qpkv/oYqNlbsvho= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535180647218.67958819939577; Thu, 31 Aug 2023 19:26:20 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IFV4PTpbDQ1XidVdKjc7jBwvSMVKrCtABdezjhFl2ncYvuUl8OIXKh33RpxEEW2wl7wgM5sKw== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, Warner Losh , =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535182471100003 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=C3=A9 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" =20 #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. Basic= ally, * 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); =20 -/* 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_si= ze()) =20 /* 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); =20 const char *target_name(void); =20 -void page_size_init(void); - #ifdef NEED_CPU_H =20 #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 hos= t_pc, uint64_t *data) =20 void page_init(void) { - page_size_init(); page_table_config_init(); } =20 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" =20 + +/* + * 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); } =20 + qemu_host_page_size =3D getpagesize(); + qemu_host_page_size =3D MAX(qemu_host_page_size, TARGET_PAGE_SIZE); + cpu_model =3D NULL; =20 qemu_add_opts(&qemu_trace_opts); @@ -408,6 +418,8 @@ int main(int argc, char **argv) } } =20 + qemu_host_page_mask =3D -qemu_host_page_size; + /* init debug */ { int mask =3D 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 >=3D - TARGET_PAGE_SIZE */ - if (qemu_host_page_size =3D=3D 0) { - qemu_host_page_size =3D qemu_real_host_page_size(); - } - if (qemu_host_page_size < TARGET_PAGE_SIZE) { - qemu_host_page_size =3D TARGET_PAGE_SIZE; - } - qemu_host_page_mask =3D -(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) } =20 cpu_exec_init_all(); - page_size_init(); =20 if (machine_class->hw_version) { qemu_set_hw_version(machine_class->hw_version); --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535114; cv=none; d=zohomail.com; s=zohoarc; b=HJZzaK219IbyBzkNXTjCBxYDPQV6QVlR+YXI2STxLOIVA46qnvvqeFoGEO9BCD2jZ7R9CVIdkOpRIJk7YEy+UMKUF1V+CAaP6cGqAJF+UyOIq0mQLP7/mAyfpiIbwmEa5xOsqb8u/5wZGU8qM/Rnr4j4CEQp5aj9rOaOXFwLZOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535114; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=v2oMFltgopchvkCHTnrNxCsJsKx6S/nBlH+XZvf6iJQ=; b=GEQbExZoJ9EtaIil4xyDQeuI89KpUqvbv1vRqiF3E6M/wCbT8AdOQVOugZ60FcP+fIULkpcWSaZjjd0ZgHe99dysoD8GIqGj5e48iGiaEugsh4gJcUImwYWVYtCPGu4gekASwrOFz0s0ExAiqLYG3NHvIElG3URQawCalVt73mU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535114603957.389745291211; Thu, 31 Aug 2023 19:25:14 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IFRkdGSIfCJdhpgv8TZpIfA6N04ObBj2uDDZG0hEfsCmeGVdA+gAB1wc/mJMb1SCOEf9G0mMw== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535116647100003 Dynamically size the node for the runtime target page size. Reviewed-by: Philippe Mathieu-Daud=C3=A9 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 *e= nv, 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; =20 static IntervalTreeRoot targetdata_root; @@ -901,7 +901,8 @@ void page_reset_target_data(target_ulong start, target_= ulong last) n_last =3D MIN(last, n->last); p_len =3D (n_last + 1 - n_start) >> TARGET_PAGE_BITS; =20 - 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); } } =20 @@ -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; =20 page =3D address & TARGET_PAGE_MASK; region =3D address & TBD_MASK; @@ -925,7 +926,8 @@ void *page_get_target_data(target_ulong address) mmap_lock(); n =3D interval_tree_iter_first(&targetdata_root, page, page); if (!n) { - t =3D g_new0(TargetPageDataNode, 1); + t =3D g_malloc0(sizeof(TargetPageDataNode) + + TPD_PAGES * TARGET_PAGE_DATA_SIZE); n =3D &t->itree; n->start =3D region; n->last =3D region | ~TBD_MASK; @@ -935,7 +937,8 @@ void *page_get_target_data(target_ulong address) } =20 t =3D container_of(n, TargetPageDataNode, itree); - return t->data[(page - region) >> TARGET_PAGE_BITS]; + p_ofs =3D (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) { } --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535278; cv=none; d=zohomail.com; s=zohoarc; b=LQOwqGIokxXrGxD4qtkq3lIYQrOkmCs5hMY6Prvnt6RZVwfd0rIAzoNq4G8wJmqfCjE2ZtdXOXEzW9pOQJuuFVePOyFFStTxoeFvTplY1USHVyx9/+RQP1imy+C/lf4bWbRbTFsViXdD6XnL9iYqfalrLp/OcnVeObTjSpq0KbM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535278; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KOXbHO/eFtWrlIqiHiO0rtMkzoeNCBbWRU+OxOKa9Pg=; b=GmQUu7gSBCCHG2DM/CMoNouYvOR6bHYziMGMiNePe9/rLD7H3ZuziXg1Xik3fmL9gMPJ1nzv4oP3qsy8SkcfcIBemrOgoVeBnF62Ab6ebsgY8KpLXsBho/YUER8WadIYsq/lk3HS7gKO461Y7967VFQo7o6sZv8LCwy/VzurNtc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535278429962.8161665831477; Thu, 31 Aug 2023 19:27:58 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IGW0tEr0XXwgScXxUmoGvRLHJs3LT2FZTt5h9MKGvJ4GvUCyaeLLtSbooONE6p0Z8D/ylV5hw== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535278949100001 If set, match the host and guest page sizes. Reviewed-by: Philippe Mathieu-Daud=C3=A9 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" =20 #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; =20 @@ -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 =3D qemu_real_host_page_size(); + set_preferred_target_page_bits(ctz32(host_page_size)); + finalize_target_page_bits(); + cpu =3D cpu_create(cpu_type); env =3D cpu->env_ptr; cpu_reset(cpu); @@ -807,8 +819,6 @@ int main(int argc, char **argv, char **envp) */ max_reserved_va =3D MAX_RESERVED_VA(cpu); if (reserved_va !=3D 0) { - int host_page_size =3D qemu_real_host_page_size(); - if ((reserved_va + 1) % host_page_size) { char *s =3D 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 =3D=3D 0) { - mmap_min_addr =3D qemu_real_host_page_size(); + mmap_min_addr =3D host_page_size; qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=3D0x%lx (fallback)\n", mmap_min_addr); --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535258; cv=none; d=zohomail.com; s=zohoarc; b=HV8v12ppph8x8IeWrWkhYmhHtkxaw9A15SfY/m0PAtmSOhdI9rOHaFVZhhtfvsMTIxsMhZ/hYpcghkP2oqDGqs+gpG6Y9n9O9hARxXOJbIkH3AsErrpgFrDNPR7USsbceOPSdP/nlcv+JSAW6FAJtMCpb6CMAWgZsFucRwAR78c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535258; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fbLJWfbE0uDldMuy5F+fdwCnCFNULQlG9yJoCgwPGqM=; b=JAGF6oZwlUnuJ+AQyITVMUjwhevCEZXxA8ghJi3LSs3NW1ZFDIGIUg6K/joyrecusGwuTRMbwLFoFRKPj3V5n4brw4VruQr6glDHZ2R3FxZqzJ+nD1RW2YUyW2E8XVWrLa2LnvOjXGBpXgvZXzClBxU8OcGUkgrFJMSdRndwwYo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535258091750.4899131656373; Thu, 31 Aug 2023 19:27:38 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IEUKnGFI8AdqxMmZ3/c6DVfEOF8PGfULOTSQDiyIWelMpYs6UQhyJAQRzWnKyxOHi3FZfGKhg== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535260072100003 Content-Type: text/plain; charset="utf-8" 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 =20 #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 =3D ARM_CPU(dev); ARMCPUClass *acc =3D ARM_CPU_GET_CLASS(dev); CPUARMState *env =3D &cpu->env; - int pagebits; Error *local_err =3D NULL; =20 /* Use pc-relative instructions in system-mode */ @@ -1968,28 +1967,36 @@ static void arm_cpu_realizefn(DeviceState *dev, Err= or **errp) !cpu_isar_feature(aa32_vfp_simd, cpu) || !arm_feature(env, ARM_FEATURE_XSCALE)); =20 - 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 =3D 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 =3D 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 =3D 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 =3D 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 =20 /* This cpu-id-to-MPIDR affinity is used only for TCG; KVM will overri= de it. * We don't support setting cluster ID ([16..23]) (known as Aff2 --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535297; cv=none; d=zohomail.com; s=zohoarc; b=LSI3vf/lIEZPaNmEJ7t0gkd9fX+QnEU9fsM4gJVvM5hqgnI7S3lpcytItQ8K+22TS4A1XuOyo0zyoWKUVdAVmGA90sQPyH+4Uut17casgcVY1VosOsO5mm8mqgnG1p6d2yfxXEfEQk/n8mryR+9z6T5Vm52I1acJN2iBZM7WtO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535297; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sLGhrncusZ++ow/925hmU4zhHqvG6lKeFI4gVIL5/yk=; b=TEwvhOyyeRTy3SG4H2kBClKFdJeLN46MaSDXcKskEri82mSA+90WQ2NiiFrLwr8RG07ZXbYXbjW+j7wkHa6MlS/TPlgMMJU1rnnIOtI6mnX/YWrqJH45stYSRVNiSBIZzD6XF5sB0mDUESsKDoYLuUCNpCXnWPg+s3BShpqqIAI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535297482245.7789262818642; Thu, 31 Aug 2023 19:28:17 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IG5f33apizct2iN6SYH/DfNN4L4x0OFoCn77zQ4AG8Y4rw71nC1XqPwXnBPaIaMd4j81MCAsA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535299031100003 Content-Type: text/plain; charset="utf-8" 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 =3D fopen("/proc/sys/vm/mmap_min_addr", "r")) !=3D NULL) { unsigned long tmp; if (fscanf(fp, "%lu", &tmp) =3D=3D 1 && tmp !=3D 0) { - mmap_min_addr =3D tmp; + mmap_min_addr =3D MAX(tmp, host_page_size); qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=3D0x%lx\n", mmap_min_addr); } --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535297; cv=none; d=zohomail.com; s=zohoarc; b=HKbP1Hb803ptFEjWUKkyQG04xRcWEYLuu+9qFAbcx89bf1HMuYqCMQbc/ZTmHau3Hzujuo+ruSXYjDs0eXNY4IS1hQm3m1cUDRTZopipfgOHxLcgnMdNoYOg5Chsqh11SZIYlbjmjdGRdVv2m9ynypb2bm1MUrtUNt5TO1cyT2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535297; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YzcEJzTW0FxXggtPi1Qrm/hCkn19peXK5YmTgg9HZqo=; b=GEYtGaJnI3NyZuWx9zbrL9E/YcM0BHuIXGwcWHPrgzaagCgfrNrrjsWaNK592rdCUnAqZx/SMgM1leIBxRjj/xQJk1Ziksv+XSnRUy3E924Mu1z3AbR23SQ/ZnjGGciwxu9O4ccqgmd9NzcaMKT8OjhhN+7eyn+SrrkZQ3FZIW8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535297602835.9223690495716; Thu, 31 Aug 2023 19:28:17 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IEmnslkpmpoflPk0bHFxu2fHYGr7hVf32XnM1j4Q1IL8CyB8Hb8tu8XaaxiJIjZHkyhTfl83w== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535299045100004 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=C3=A9 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 =20 #endif --=20 2.34.1 From nobody Thu May 16 11:31:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1693535151; cv=none; d=zohomail.com; s=zohoarc; b=L3Pm4y9gG66sfJR4n+sjZrHJM8WNgcTyhfDOe9ALKDzuqJ7YWaZcT7556nw53a6tNdyPJyf3WKkyTh44yxesuqwiSms9oZiDgtJcXcOGHrQKy+tfcJvMgjP/scB0LWgBJGL5R3iuhHxlZuwEeZpS0ktZmssWof8rR5E9P/Oy/P0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693535151; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UM3G3JW9WxcLT5Dzb3w4vT9giwKkE+uVqc4Wz3d/fxQ=; b=QBvkPvmcFaoSSUfcL75CmwMFxtPK1FrFWzUiWl/7nBcIDqaUpVihUTjNcCAgSUQEaj6uFfZT3o5C5f+RZuNSDhnDdmd0ChWZcMMIDTiB1sEAvNdLvER2ctdQ5WRkuIJxJN22MwkHy8d9sQbjVghxxsHqla04mKCnTI5SZ0oZVIg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693535151546452.20339209731435; Thu, 31 Aug 2023 19:25:51 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IFeWhEix0PiAx8keqXc00mLa/nUIYMptZ0Rc/yTpfngUDY+40qjoCdatFu/e6QLGnsflL2/wA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1693535153294100002 Content-Type: text/plain; charset="utf-8" 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 =20 #define TARGET_LONG_BITS 64 -#define TARGET_PAGE_BITS 13 =20 /* ??? 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 64= k, + * 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 =20 #endif --=20 2.34.1