From patchwork Fri Aug 18 17:11:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714651 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp628564wrs; Fri, 18 Aug 2023 10:14:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHuINiJcNvsZIOE40sBBBnHbifIMM9xSJ2+BMVw8w7pkcxUdGDipa4ghQJAC3dckUzDTBkZ X-Received: by 2002:a05:6871:8a1:b0:1bb:75af:37b5 with SMTP id r33-20020a05687108a100b001bb75af37b5mr3765259oaq.10.1692378867440; Fri, 18 Aug 2023 10:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378867; cv=none; d=google.com; s=arc-20160816; b=ysNlxL8mEDDUDVsduV25KSCNsrKybakawLPDtQcOWIMPo5tOLedp4Pc8w9it4zJfOj Ua5fAxKUOdIt8H+LHa3DztEwFhe3iTIB4ymmcShQ+vaiTDib//AQDOdKP0yTNrnJWmoz MB+Wl4lvgChj1Vk0AKV5lgXLkg1TD6hO/hYET7sHu2hi0mvBAvt4i1k6+EUREY0HrX8P QhxFFQ1+AlfuzCzty5XXQ3IkoqVYvcdOGYmlv+fA467geRXH7MBtPXHI414NEX5beDdI IdGJSCnXQYa8lUheHVQOffYltx5ksVACR7mwYO6hHX20WGCHsxI89aKzmyFQDUpJyye/ F91g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=X0ddZs7bYg6jrh/HugPDxFYzx9+2rJ0wZJYAYZEah5o=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=Y4TOQbXYWbRVunf8BB7Wn5dCNH6VQZwaVVQ/vDEU+vWiRxH0us3AqBifjG77x25dPS JPDAVLLOlx0+FtVgy7JAJXHYisGXu80Hk8uJ3yjeLWLC3Ifutj+HIz4NDZ58GzfZ5uWF vy0fPjOB4lp9AdtAi3om9gl9hJDSH+SYKxeUslBuMF5nR/v172PqqzikJyu6LmqT2DqQ /2rXKlBjzXTNVwSsbhdsElZHEFX5orqPp65bx/W7yT6+EAvIx60CGagjoWDYdy80/UfY QOqA6eaAioTmHTTNm6ma/ry5fUGZkafyxx3O41Hs9U+qGUNsgLMVrM3duDS9ITjZoydy 8xnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VGk7PeKL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s13-20020a0ce30d000000b00649529b977bsi1621383qvl.434.2023.08.18.10.14.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:14:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VGk7PeKL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31Y-0008AQ-J0; Fri, 18 Aug 2023 13:12:36 -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 1qX31W-00087j-LE for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:34 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31U-0007vg-1W for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:34 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1bc73a2b0easo9418285ad.0 for ; Fri, 18 Aug 2023 10:12:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378750; x=1692983550; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=X0ddZs7bYg6jrh/HugPDxFYzx9+2rJ0wZJYAYZEah5o=; b=VGk7PeKLqdfF72ht+ndfGJS6D5wz2xV5SX3aiX+ZYJdjq6NcR3J8+P9VlEfaWWqN8z jhsvmkugVfWSGnQUMdbFFOx4aIAaIgSRyO+0tSjZkO+zt0TSOfl6VefUkmq/VJZCuo0S pEdjM+5tSP2TenVFo87YuOXGN8+96mPNsgFOfuxPQJq106jxBRrM4ty2sdIXuPmlCk4j o1EldJvvzcNn/a9OXEixKzVevb0JoLDNJ7Ikcgc07SXr+RwZzrPxPwzyKdciV+LX7O0V P8+twHTEqopfaVsSVqh8cP6smG8+cpbWqH0rV9CWxb/YqIyK4COOmEMMHhnTgd4PFeIY Im3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378750; x=1692983550; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X0ddZs7bYg6jrh/HugPDxFYzx9+2rJ0wZJYAYZEah5o=; b=bfKR5DMRYEuSdLvrGOlve6vRbQwVPBSgCPHCicTXfp3pvOSN8h82fW2KDhVdPiBl/h 9/0Y5Iez3jaTTjVR1Ps7oNQPEDIOsUzY37jxwc8klLSGo/VhCL7P+snTRLFocXHpqfJZ 8kH2FTyIDWjgYVYYr5/5qADJSgExjQsda4r5Xl4O5eLBnF5gu3+PPWcCECKMJy8JLLQ7 Ezk/RP9/OZ3oiEZStPfz7Cw0uAoCacW01TeFlZU2GeOCsN508ZIWup16R5Bj/GT+F22d vlgW8Qg3BHlwvySjxcDrrll/MQ/FdNiy09iacMhdAxCbjfFbxgJSYRPHwaU68HL2HZ4t 444Q== X-Gm-Message-State: AOJu0YzIOn7K5bvLQx7UyZAr/RWtiRRb3aYILbmQsJPxpZ4Zw/eKuz7i DnChrqdKxO5jdTN1rabaHucsM+JQTLJWg2iQpYM= X-Received: by 2002:a17:903:249:b0:1bf:20dd:786b with SMTP id j9-20020a170903024900b001bf20dd786bmr3774704plh.31.1692378750364; Fri, 18 Aug 2023 10:12:30 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 01/33] accel/tcg: Remove qemu_host_page_size from page_protect/page_unprotect Date: Fri, 18 Aug 2023 10:11:55 -0700 Message-Id: <20230818171227.141728-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use qemu_real_host_page_size instead. Except for the final mprotect within page_protect, we already handled host < target page size. Signed-off-by: Richard Henderson --- accel/tcg/user-exec.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index ab48cb41e4..4c1697500a 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -650,16 +650,17 @@ void page_protect(tb_page_addr_t address) { PageFlagsNode *p; target_ulong start, last; + int host_page_size = qemu_real_host_page_size(); int prot; assert_memory_lock(); - if (qemu_host_page_size <= TARGET_PAGE_SIZE) { + if (host_page_size <= TARGET_PAGE_SIZE) { start = address & TARGET_PAGE_MASK; last = start + TARGET_PAGE_SIZE - 1; } else { - start = address & qemu_host_page_mask; - last = start + qemu_host_page_size - 1; + start = address & -host_page_size; + last = start + host_page_size - 1; } p = pageflags_find(start, last); @@ -670,7 +671,7 @@ void page_protect(tb_page_addr_t address) if (unlikely(p->itree.last < last)) { /* More than one protection region covers the one host page. */ - assert(TARGET_PAGE_SIZE < qemu_host_page_size); + assert(TARGET_PAGE_SIZE < host_page_size); while ((p = pageflags_next(p, start, last)) != NULL) { prot |= p->flags; } @@ -678,7 +679,7 @@ void page_protect(tb_page_addr_t address) if (prot & PAGE_WRITE) { pageflags_set_clear(start, last, 0, PAGE_WRITE); - mprotect(g2h_untagged(start), qemu_host_page_size, + mprotect(g2h_untagged(start), last - start + 1, prot & (PAGE_READ | PAGE_EXEC) ? PROT_READ : PROT_NONE); } } @@ -724,18 +725,19 @@ int page_unprotect(target_ulong address, uintptr_t pc) } #endif } else { + int host_page_size = qemu_real_host_page_size(); target_ulong start, len, i; int prot; - if (qemu_host_page_size <= TARGET_PAGE_SIZE) { + if (host_page_size <= TARGET_PAGE_SIZE) { start = address & TARGET_PAGE_MASK; len = TARGET_PAGE_SIZE; prot = p->flags | PAGE_WRITE; pageflags_set_clear(start, start + len - 1, PAGE_WRITE, 0); current_tb_invalidated = tb_invalidate_phys_page_unwind(start, pc); } else { - start = address & qemu_host_page_mask; - len = qemu_host_page_size; + start = address & -host_page_size; + len = host_page_size; prot = 0; for (i = 0; i < len; i += TARGET_PAGE_SIZE) { From patchwork Fri Aug 18 17:11:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714658 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp629224wrs; Fri, 18 Aug 2023 10:15:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGgVvCYL2XW9NnmjRxbjZG8d8xZtr5wfJjHGrVikiVSi4YqcJccZj2Xlpx5JCeyCtMvq1ec X-Received: by 2002:a9d:7c8f:0:b0:6bc:de62:86b with SMTP id q15-20020a9d7c8f000000b006bcde62086bmr2968028otn.7.1692378925962; Fri, 18 Aug 2023 10:15:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378925; cv=none; d=google.com; s=arc-20160816; b=WYg8Rk98mKfSJbfS18q+rg9JtcTJkOFmPA0At7h2298x1B00p4kDFYmyy4u2cDndpm rO4s1qlBAlwjfl8KXUUEAq8uJhYKZPZTyGoc/b6s0gTWuOT/xzVjkCblC/q0g+m53B8i ZPdeQrrK0O87wWnmuXgAvKXXLx4ANqpXuv4QvZAeVFBw4fuhOyNYln3SO3PEo6R1Ezho R7acMgdUb/BEjWco+VeX/g0fX5wbbVNxhmUocJQp+NkqLAtPej0/Gk5kTOEYbAjO6m0U FC5dcU2hmE/tK48igrJ1OKL+hGO1b5lhnHK/AaEzWeibEc24KgDdP/bpyzGByJcfvgum YDYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=6UB9ulXi57KJ9LgPss7vEG9zn+ZrgirznyOZ1XFlP64=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=x3KSwLV+s6QSg9co3ZO1v+IzX6InXGUlmxvnXHQ8NrTtab9cQzSVRTAY6s1IiAczKw waj5u9Xl8qeFQk1bcDokzLl8uDyA/2m/qt5UF20bFo5wPOSu4c2F95hBnTHCzAUE8dVU kwL3smZ0aGg9wZuHCIVXqnFQJBcazcEeO0p0ACM4QPymWM2aTY9xN7i0JYHkhgn/zrKP 8m6idO9i9/36cP/dJC3EEZMXEZDsKSq0bAS7lxJWdmz1Xb6YjJWU2qwUtWuS1eW0v3Cj e6I0MO55fDn72hPq0N2CehR8VCLJvNUs7C9twWbPh2mWvblfklD0+vhk0/JkBSoKWDPg D3Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OQVa88hB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d13-20020a05622a05cd00b004055a48136fsi1514415qtb.129.2023.08.18.10.15.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:15:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OQVa88hB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31Y-0008Af-TT; Fri, 18 Aug 2023 13:12:36 -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 1qX31X-0008A5-RJ for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:35 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31V-0007y0-LE for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:35 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1bdca7cc28dso9448735ad.1 for ; Fri, 18 Aug 2023 10:12:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378752; x=1692983552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=6UB9ulXi57KJ9LgPss7vEG9zn+ZrgirznyOZ1XFlP64=; b=OQVa88hB63QMu+lzD8vZouFOliYx8O8WiCzqzSdSIVI4VYTHD9ipAgfJsxMxTVSfO/ SKv7MPOinIGcUEaIufPBF8KE4/Rxghhk4G1Uost77jwjp18d0UPP1a2jfSkBL+NIDjea nEs2Qj1S+kwpGeQ+eBwyOev48Ey7PIVXn8C+TjrPl+HTC1R8ZjNXAXegjAU8a4Qbrnbr Y0L2P5YcNwIwdvmV8e6aiOKHF/acaqOf82jGoecEW+c7OvBVAL6LPnM/TS6ohFdWpS+w QaCwAJcucflzwDceaYXUZjVI5Eh1Ct1ATk9diGNDt/P6kEbG+CG0kHvcMJaFb8XaeRjx Uoaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378752; x=1692983552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6UB9ulXi57KJ9LgPss7vEG9zn+ZrgirznyOZ1XFlP64=; b=h6SAeyP4IeDfWgfSv+OKFO7QHOZKSQr2QMI8JE9L3vy3Uw6zPxKwJhxUzETmP7R3PP kPFX1tXGEfkGmsDmOkfiTpBXGmI7EEfaXYvIWSiCaqVm3kZJbQwP1TtvvlTJqLuMgL/B O27/HFKvGGwobuVAOKGZf1bGEHKcyj4yGhbRqEO9hRr5eu+gxiQSAlzy1WrEuRkbYHEW Brp9vNc5Spj55tqUbL/6MWM2x3Bndv1amxxjGn61TaCfakbosxnR6eVsyks6Z3r/RlNu ja5jWTBSDB6fwnLdmeXJlXtWqQ+bUUnVbwjtxnZ3hVBJPsRm5+JmBs5P7qbDQmr6R8v2 5x+w== X-Gm-Message-State: AOJu0YxR4a9CF9o1JrPG6mfiQPdQTmCTpFBqOlU8ut312hLJ91IuYqq0 NzodpF/GY4NdaWQpMi008rPwP+7SSTOj1eBrtfM= X-Received: by 2002:a17:902:e88f:b0:1b0:f8:9b2d with SMTP id w15-20020a170902e88f00b001b000f89b2dmr3652501plg.29.1692378751944; Fri, 18 Aug 2023 10:12:31 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 02/33] linux-user: Adjust SVr4 NULL page mapping Date: Fri, 18 Aug 2023 10:11:56 -0700 Message-Id: <20230818171227.141728-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use TARGET_PAGE_SIZE and MAP_FIXED_NOREPLACE. We really should be attending to this earlier during probe_guest_base, as well as better detection and emulation of various Linux personalities. Signed-off-by: Richard Henderson --- linux-user/elfload.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index ccfbf82836..9865f5e825 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3749,8 +3749,9 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) and some applications "depend" upon this behavior. Since we do not have the power to recompile these, we emulate the SVr4 behavior. Sigh. */ - target_mmap(0, qemu_host_page_size, PROT_READ | PROT_EXEC, - MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + target_mmap(0, TARGET_PAGE_SIZE, PROT_READ | PROT_EXEC, + MAP_FIXED_NOREPLACE | MAP_PRIVATE | MAP_ANONYMOUS, + -1, 0); } #ifdef TARGET_MIPS info->interp_fp_abi = interp_info.fp_abi; From patchwork Fri Aug 18 17:11:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714642 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp628207wrs; Fri, 18 Aug 2023 10:13:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfS95Ra4HKx+bsxY+zA4qeS8en4vvz7mh+KGY3OsAxWXSswzaqWUd8ri852F7GdsmqNUd+ X-Received: by 2002:a05:622a:1052:b0:40f:e176:ddb7 with SMTP id f18-20020a05622a105200b0040fe176ddb7mr4136280qte.37.1692378831847; Fri, 18 Aug 2023 10:13:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378831; cv=none; d=google.com; s=arc-20160816; b=fBvVHtVArPI9nAtSwADaZsUNRwaSNqnOljcJPSFCRcJzzkdwfShwIr44SE1ojuP74i cFJz/zwFZYDNPcEDeieuiJIbvunjUTi2QFvDZqSBZQNN1kpLspeDBzNdA5DRVQg7H7kg wQJ1RMjdrnocBVZ+8pV7OYbohbkJGF599D882jFhiU/6AEIWoY2y53j0+vao7bZq3waj +NEPf5/YE3N02PQ/fSBfy2kdVBZV+aP61oKn4XJ5ZJv7/w5GFJfTx8Nrw/csrskH25Ka uP8AJWB527aRUb29LjD7uGT+20WRKoTI7zxSVPfNZz/gjH3S9+/4DRPH/2E5k6JBMoKl ZsJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=b6QumjYXJdEchv07+6JwQBzFkrW+HsuAnJDB/FfxSIs=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=SjIS13YIx74atEHQoduOQjzTdT5M/O0soYt8QstB9GkAqAnSB052Rt0pmr94O7SDMK Z3KTnpFPdsdIVCxM+XFtdyFI2TgdV7q2FtMQfFwm20Yk/j4Usn0dQaFZqhoy6MDkwdyb Oq0rDMoh/sdMnhZr6AHaSG4wH844maE8ZeQ9gItu1vzaWsvd6LJNVAFbxaHQK0ozLDim IHjRagpnVSgZu6Eeriy+0/ex7GZntFOYqHP19jKN7VTdyry8x/Nd/yKmCw/noNcTFcS/ PHXWrGmqu7WxjpTxe7miZ50UBa7sbcU6gKzhabdObnRxCBDXQg4L9CyKFaccXCXQEaoJ dScQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JUmAXIJC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d19-20020a05622a05d300b0040d3e5c0d0dsi1531851qtb.377.2023.08.18.10.13.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:13:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JUmAXIJC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31a-0008B2-7d; Fri, 18 Aug 2023 13:12:38 -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 1qX31Y-0008AR-FB for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:36 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31W-0007yZ-BT for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:36 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1bf0b24d925so8683335ad.3 for ; Fri, 18 Aug 2023 10:12:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378753; x=1692983553; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=b6QumjYXJdEchv07+6JwQBzFkrW+HsuAnJDB/FfxSIs=; b=JUmAXIJC20D2Qcun6L3kV4XxmS0dBqqFkHN8pycwa24PIqxu0kjr/UK/B3DOL32D3n 8w+KFtcQHEPpQBSZqGMm40L37h4OMYf/42sn9ukjrRrWEV0nJH6x1s1nUZgvDDg5odBy 4IG5vkW7vT7Twcu4ehGa3C9HO6qmOxXaylbcgqIuMumyhBJTnVFzJcL0bXJpqriA78/u 3+H6vH+pMKYhzPddfMRXLNqfHA2dax2wryJRdxte296enbvYK0UH2nV7Nn6nfiD08fCI Bsd1C7WrRC0bJKy6keRMkCA1zjhHGvB13ALOTjWyP/Ab1etcNUht3HKqrxe1Meie1NXN Qv9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378753; x=1692983553; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b6QumjYXJdEchv07+6JwQBzFkrW+HsuAnJDB/FfxSIs=; b=Fgv1ER+GRWX0uJJMeYifF6tAl+2ZTwp2wABLJH+42mvGl/bGFVHWdtHfeyzOz3ql4o GBnLRnDv2jkNUUZN/EKhZmv5K7gqgmKdoGxEOTkw4iXn7xOwBO0x9oSJnyEgy1t27dNT jan6lkTR6DPsXocWLxbrojIdxRCJahucUQAznLegbHyaZz03ln7V+8gQJPzYFPHDzXSf oqvjEMc+1Ta50PBfGXoBtU8zTJbG7FIqBmkGj2iGt3xlm/tOPcQPke1tU7Rc596fEF0l 1gxaS4Q9+y0LTXxua8eVlL8G7RtQCBMAuMOVjog90K1TXgepQXNqhrOw1dSANjO45RKd SL9A== X-Gm-Message-State: AOJu0Yy6Vl2oyK5/plKKAtdmK+S1PBIDE/i0mHOcUjl2KYF4z1L4JoqF 2WCrvi10U5qUlzGyFACASJ+5hMfmIJZDPYE0YEo= X-Received: by 2002:a17:902:e80d:b0:1bd:e64c:5c71 with SMTP id u13-20020a170902e80d00b001bde64c5c71mr3766543plg.21.1692378752776; Fri, 18 Aug 2023 10:12:32 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 03/33] linux-user: Remove qemu_host_page_{size, mask} in probe_guest_base Date: Fri, 18 Aug 2023 10:11:57 -0700 Message-Id: <20230818171227.141728-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The host SHMLBA is by definition a multiple of the host page size. Thus the remaining component of qemu_host_page_size is the target page size. Signed-off-by: Richard Henderson --- linux-user/elfload.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 9865f5e825..3648d7048d 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2731,7 +2731,7 @@ static bool pgb_addr_set(PGBAddrs *ga, abi_ulong guest_loaddr, /* Add any HI_COMMPAGE not covered by reserved_va. */ if (reserved_va < HI_COMMPAGE) { - ga->bounds[n][0] = HI_COMMPAGE & qemu_host_page_mask; + ga->bounds[n][0] = HI_COMMPAGE & -qemu_real_host_page_size(); ga->bounds[n][1] = HI_COMMPAGE + TARGET_PAGE_SIZE - 1; n++; } @@ -2913,7 +2913,7 @@ void probe_guest_base(const char *image_name, abi_ulong guest_loaddr, abi_ulong guest_hiaddr) { /* In order to use host shmat, we must be able to honor SHMLBA. */ - uintptr_t align = MAX(SHMLBA, qemu_host_page_size); + uintptr_t align = MAX(SHMLBA, TARGET_PAGE_SIZE); /* Sanity check the guest binary. */ if (reserved_va) { From patchwork Fri Aug 18 17:11:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714667 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp629747wrs; Fri, 18 Aug 2023 10:16:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGklBq7521NTSu9h3f+9FVd2JSSitx2fI41Jg91nJXlrT8COtsIGvOSONDl9EllFPctKvr0 X-Received: by 2002:a0c:f28a:0:b0:5b5:9c2:8c29 with SMTP id k10-20020a0cf28a000000b005b509c28c29mr3560159qvl.12.1692378975041; Fri, 18 Aug 2023 10:16:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378975; cv=none; d=google.com; s=arc-20160816; b=zlBEAJiGrFsGfmKtHR3+KlhRlcdAVcmTnxzEaxvSPU+8JDp8u+S+ScIQtYKk4jhd8O nWnb+jxUWl1LvUt7O4pSTAcz+181JqMjyf1xB9pjvmovF4Wj0mMS9mNmFoMEUHlU7Sn0 +CVBXzjV8AyXCqD5MnnHjI97un9NnWk4QNGyz7zVYwFWefQcKbJMrhRUWCnmyjfxjpEB JyGpoewU4zD6WRhK2XC4qZ8GZkgJoFAT6T+HP8AYxmuErCm/YeRp9hz1AE7zFsTXzyaX y6cAJqQMt+PuovTzowtUpy4Hut7hOF2S0YAcOWSbFZso98qvaWi2rW01gYUzSiMRmnB/ e0ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=091aIS/ULzwKFsYVlk4LamXD09yyDrpVMY8mRCUEE8k=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=kCS5hBRduZZtwHUYSCF/4OOwkFX4ak+BcnwVvbWeZzXfndZmLn8gnm0HyKVavKJbOU bgoLwDoiZG3IuL89yF9lGxlxn+NhKC8xcOt70boPQj4TCNFzVZkbC0/nuFajRPk65SUL jF+u6UzPpSDME7KMh4Z7iJ/yNGB9d24FcEIiVYjtvWlWKngQdJC6EJd7O4Nfu6T6YvB5 rAtEAJq/21R2y3/5XJtm0Lrh3ZOw6Kssb+j5urmCGY2CBhuzL+ydTkVORt4WFhWPQl3v jnzlhhvU8IyR8u2MT/axpgEzlU22ndfOJqztmvrUWkWYRlk0xFygFQqSTw26Dm7DATay Wyrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jSGjG3dp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c10-20020a0cf2ca000000b0063631ab5dd9si1535490qvm.164.2023.08.18.10.16.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:16:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jSGjG3dp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31c-0008Bm-Hd; Fri, 18 Aug 2023 13:12: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 1qX31a-0008BE-NY for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:38 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31Y-00080C-JA for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:38 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1bc83a96067so8710565ad.0 for ; Fri, 18 Aug 2023 10:12:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378755; x=1692983555; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=091aIS/ULzwKFsYVlk4LamXD09yyDrpVMY8mRCUEE8k=; b=jSGjG3dpIAAp31YOpMrsAvmz+/qLTFUC/P/4rqkDhgPl2Mst97hfZ/dhhlEcRWFD67 6+GyO04gisPq+dBLMYkC25I1mesgCtLJwoGUOrncTvQdopky9s1/yGY9QQ0R0Mn0G38H WhhzPFCNkWEvgAM8dogCl4pjmr0/UCUVvX74K1Tfs1ElvhO9yW2cr8zBgQfaHmgYTrLc 1K1nWmzoUzyIBuPChhFdW0TGMCCOpMmdEmAoJ2Veg7TUVXziFrTXiS/X5bca/VSb0ZeV p9ORbDVju6Xq3RH1bv/OSvnVYc26aTpzQ0/S1vpaAOALR5IpduWZU8TiT/LCrDxKDf6X QwXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378755; x=1692983555; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=091aIS/ULzwKFsYVlk4LamXD09yyDrpVMY8mRCUEE8k=; b=Vktcp7+uRDjPEed5qyDepXO7QAmJAAK/PUj21KMc4WgU4u5kjOrImXuApUpavxnU+I BpfuhYLvSDpYQMfgZoKu1wT9+RoK7PLRzyeIWHAUTRWkr6mvcV9U/UbPalU4Ajxukx38 V4tP6BXyWGqa3vUgbXgs0LgLNoRTt0ke9tdojRhhJsZjnoeriBDmKVpM+3TdjTpqXCUc ZrPd26rxss7bZnt0QZw17CdIB9urxWia6rXyzBgG0MK0oO5jp7trnd28dFaxlNWK1Aos GLtT87E7gOGljuKcKZ0fvYmGoZhXS/Q7vXg6+oHI3dfR2G5uDaPRevZCxrvz9tXh71yq nLVA== X-Gm-Message-State: AOJu0YwzITMUUh8Oa4ry7wDs63dQTSnJfyef6IMcem47rGxt0/4i2lpm TF6ux55n0urdMppV6nrFvjbyYdWcn8giryrjcjc= X-Received: by 2002:a17:903:1248:b0:1bb:d59d:8c57 with SMTP id u8-20020a170903124800b001bbd59d8c57mr3192306plh.18.1692378755155; Fri, 18 Aug 2023 10:12:35 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 04/33] linux-user: Remove qemu_host_page_size from create_elf_tables Date: Fri, 18 Aug 2023 10:11:58 -0700 Message-Id: <20230818171227.141728-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org AT_PAGESZ is supposed to advertise the guest page size. The random adjustment made here using qemu_host_page_size does not match anything else within linux-user. The idea here is good, but should be done more systemically via adjustment to TARGET_PAGE_SIZE. Signed-off-by: Richard Henderson --- linux-user/elfload.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 3648d7048d..b6af8f88aa 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2517,13 +2517,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, NEW_AUX_ENT(AT_PHDR, (abi_ulong)(info->load_addr + exec->e_phoff)); NEW_AUX_ENT(AT_PHENT, (abi_ulong)(sizeof (struct elf_phdr))); NEW_AUX_ENT(AT_PHNUM, (abi_ulong)(exec->e_phnum)); - if ((info->alignment & ~qemu_host_page_mask) != 0) { - /* Target doesn't support host page size alignment */ - NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(TARGET_PAGE_SIZE)); - } else { - NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(MAX(TARGET_PAGE_SIZE, - qemu_host_page_size))); - } + NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(TARGET_PAGE_SIZE)); NEW_AUX_ENT(AT_BASE, (abi_ulong)(interp_info ? interp_info->load_addr : 0)); NEW_AUX_ENT(AT_FLAGS, (abi_ulong)0); NEW_AUX_ENT(AT_ENTRY, info->entry); From patchwork Fri Aug 18 17:11:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714663 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp629652wrs; Fri, 18 Aug 2023 10:16:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0Na0BnXiPFp0pHoK3tOl9m5Z2RKr9gmp7UdaLn4GlVPCHnQWt+wrF55+P3E8zHNJP+frF X-Received: by 2002:a05:6358:93a3:b0:135:85ec:a080 with SMTP id h35-20020a05635893a300b0013585eca080mr3727943rwb.32.1692378965471; Fri, 18 Aug 2023 10:16:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378965; cv=none; d=google.com; s=arc-20160816; b=siAOwFVWMXebwnmMSFFa4ovnjDxtnr6AMFvGg7r5mdZpxs8SUfuIdB4JriJVDsi8m2 NtIAgiUHCz5gDUmPGTtQSN/ZhHqqolHIYZ2WwX+x+J33StVQTG2Ogaxr/ztCdVsBBch5 pDUsqn5ugVQL8bIJXUdj60C2aNAi9SKbvBuQXb7eCOrQe/m3Em454iB0DovDrsc/qg6v pVuHYpekj3izTQW4NZZedQRE5sI89Xwv7cyX5F+keuozFasDWBToA9WahbqZOGvI1BG4 sKi5yknRqYzwz9LZomzaedweoo8p0YHsQEtERTMn6673uahUUKN/sZCE9l4ywbks/5CM ZGig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=foxS0Fq91WmmfcDM8Wf9D08Fa/T038sYWUjuA+SoAyU=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=MtvNV6j8MTPZYWnvooGuQDmFyqdeRLg7WUKQ+sbS94nKY/p9fvuYWm/Z3En9TpZFFe P91nTuysI34ljdCzqbLk6/up2syjueIE/AieryCejpz09tTh0mq0yHp6QD4heThLf+/5 V+iCu/aNKDwW5beE5cIjmJfmUSE11ut6RGWO8naGO3kZJmjUHHJWnK3FNeqtWmhUmIQx PVMusneOc8O7vL1eP0G7iuMzcJ7c4euGJnub3WhW+nqG0SCOdL14bOYEmN2TBtk+PCBm KlO5KtegUxExdW8i0o6jOuUqz04Ux43rxNIvJkOrnSWPwQtyHY9SCpcAciIqPOw++0Vl wLSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J8ufQCj3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s12-20020a05620a254c00b0076d8821ad1csi1400789qko.587.2023.08.18.10.16.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:16:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J8ufQCj3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31c-0008Bz-Ps; Fri, 18 Aug 2023 13:12: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 1qX31b-0008BS-Oq for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:39 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31Z-00080Y-Mx for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:39 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bb84194bf3so8859755ad.3 for ; Fri, 18 Aug 2023 10:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378756; x=1692983556; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=foxS0Fq91WmmfcDM8Wf9D08Fa/T038sYWUjuA+SoAyU=; b=J8ufQCj3bDBvRWuA6trLxcsZRKMyceecEnvjHX7M9colkmTNmxorIIcuoItIknNd2b HHlOjxf0ZzGCbMCom09fMncmsOtsb9THDryk5Pe1k0tD5lFl8i+DSbULcmqh2t9CtXva Fe4PzQSdNZluTtIu/RAmwcoWvy66U8Js0EVg2v8DOiYyrNpuGJ5UIBJ1u71vXHcScz2K 5OJdpZOBZV/20ER6SDz7+crt2Ks1zDQ+nnOVsoSwnl6iDVWbUk77T8FZxT7DN2fLQxTB cwZCwMjKMibjgszE+Dfvk8mxVkmVmdJKF2bvY7wrIW7n2nrq4jmfW5QEmrrElbbdOD/E 2dXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378756; x=1692983556; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=foxS0Fq91WmmfcDM8Wf9D08Fa/T038sYWUjuA+SoAyU=; b=BJmFd9ZxEwSk2sSJ0yEG5PY5HT3LeZ1F+FSyRAZK09QrV8nJknKKgMdTIMKtSQxRhS U+sPoDwNuTmpLI0KLezixzC2Vx19WbMEWUQs8NlhdX7fpKMfYv1TOj6/Y1Cib8nsR412 YfuC6nXOgoy40TBZMwds80Hu9U5tsAS7718WppDyzIAECCUu3hbu8GB6ONJ1087J8+co e5iWK10/BpXL0p6ynuAgdYK3NA+4Dj3EwtyPSb8U5peuOsitZN4bcQHhkvhgIoSQg7OX SutL9Gm9whYhgvZp53Imr99BVOgOK82ORPQngILBpLseNpWFIAI3glTOsN15NpxvqLsZ luhQ== X-Gm-Message-State: AOJu0YzoP51sC2gsLYfn7kAY366WP9BpiZyy8n0QMfEJY+rXEjLu8dfB dx/Bf3RiDOXNaax9Rb3cFmNHEFkepgk53SZnssc= X-Received: by 2002:a17:902:8341:b0:1bd:bfc0:4627 with SMTP id z1-20020a170902834100b001bdbfc04627mr3090319pln.40.1692378756303; Fri, 18 Aug 2023 10:12:36 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 05/33] linux-user/hppa: Simplify init_guest_commpage Date: Fri, 18 Aug 2023 10:11:59 -0700 Message-Id: <20230818171227.141728-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org If reserved_va, then we have already reserved the entire guest virtual address space; no need to remap page. If !reserved_va, then use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson --- linux-user/elfload.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index b6af8f88aa..1da77f4f71 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1831,16 +1831,21 @@ static inline void init_thread(struct target_pt_regs *regs, static bool init_guest_commpage(void) { - void *want = g2h_untagged(LO_COMMPAGE); - void *addr = mmap(want, qemu_host_page_size, PROT_NONE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + /* If reserved_va, then we have already mapped 0 page on the host. */ + if (!reserved_va) { + int host_page_size = qemu_real_host_page_size(); + void *want, *addr; - if (addr == MAP_FAILED) { - perror("Allocating guest commpage"); - exit(EXIT_FAILURE); - } - if (addr != want) { - return false; + want = g2h_untagged(LO_COMMPAGE); + addr = mmap(want, host_page_size, PROT_NONE, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED_NOREPLACE, -1, 0); + if (addr == MAP_FAILED) { + perror("Allocating guest commpage"); + exit(EXIT_FAILURE); + } + if (addr != want) { + return false; + } } /* From patchwork Fri Aug 18 17:12:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714660 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp629488wrs; Fri, 18 Aug 2023 10:15:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGHAgiz6r0OdwVyIoqI+NO2VCzSgybO2jxBDT22Bywo0jwGcXOiakIqQsN5r780PVtU91Ii X-Received: by 2002:a1f:3dd6:0:b0:487:62c1:f093 with SMTP id k205-20020a1f3dd6000000b0048762c1f093mr4250148vka.9.1692378949580; Fri, 18 Aug 2023 10:15:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378949; cv=none; d=google.com; s=arc-20160816; b=aFOcLoz6enk3LBVklIoPBKcRniSV8MwZy/3D1d0qhniHA5V1D2G30kBt+LJ5WtgKOu CoDwHzqkxHmyJKg+XQ8NNailkzToGG6z76+Gd7WWoErgcRWvNba0f4EKj74seMPk0tgh xbFcdZukxvyxk33Nnh2ERmxa365pkNNw2HgjIifrGiy/H+EbkSkZgpf2fESayQyaK9QA tLa3lu+h9bcXkDNlwCiXsCEffifDG9vJxpgs6eZETmFfFzh5aGpALcBO9kchR8GRhfqh EpmcduQ90IYi4FUeFwmo/3MZzaADzvjK6I28IL6E+9sTOEyYZ34pQyXsfbrFQiTmP22S WNDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=0oPq687I8gk8ySwy0mlXFIb93Ar57v3iR3Wlm9NlHFI=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=xPhnUOmi8ww1mNlglpm5d5+gtklcptupzBF1w+8CZ6ZbtL3SnOAoP/yyySKtG6E+53 1c2MJLoOGpkTF7OljC0rcf7rx2bzDYK0OWtY5rVUJzobToYd8pkwKHjZ6kYjqwBf/N4W /euPbq3E54VgwNxEtcbaOtGzGSBU2bGaF3QEidzaaFTsRhugxpwBlliOHGZJz0eQcPJh NQh62dN2twlrYaOKNhr5ZUnsLMuuDCvy1PP5IWQQg5PutixxxAL5fnHgJ/ulDGQn8dCq LykB323lsesuO6trOI2zCcQ/ClV1acMlTwfT7yuW4kesqfBYraOakTDHm8Yr9WQ+Ldw8 3roQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vmc2IQJL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x2-20020a05622a000200b00403aa8095aesi1500374qtw.665.2023.08.18.10.15.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:15:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vmc2IQJL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31e-0008Cp-Tf; Fri, 18 Aug 2023 13:12:42 -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 1qX31d-0008C2-3c for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:41 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31a-00080g-Uu for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:40 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1bd9b4f8e0eso8772685ad.1 for ; Fri, 18 Aug 2023 10:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378758; x=1692983558; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=0oPq687I8gk8ySwy0mlXFIb93Ar57v3iR3Wlm9NlHFI=; b=vmc2IQJLODukeOhaYvmTN11MG4mOWAmMCBhQ0KRG2VM7N3NCamAF+7tP2uAl3FLb54 hri7BHSsknudn1omdjnVvqEFr8effzfEdlK6mOWCx0we8yog8XRFu/owqSo4yC06+gJB 1w73kJOlxDbveucvskmTCuRbDLwP0n6k94cJil9192hTqQ8btAThu4QHto0XkUYw7UvY 3xv5JwLrR9TQW45XKDlYOW9cfmLvX/+O0B/6empgghzUlcY2abMCAHReQvE2zftrpsQ6 csElQYUo8wad4RFLw1pBDjy7IZTL4p3MmDjYRflX38uKo9BcATWuj6WVmuz70r5bdx01 3aPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378758; x=1692983558; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0oPq687I8gk8ySwy0mlXFIb93Ar57v3iR3Wlm9NlHFI=; b=LxjRWYhqlhWEZ3YllZ09d09sV0AYUlABNa7tKO9XwS5/ySv273wvr3P4T4lerWMssW 7qG3eHrX7sBzRSDtcDRdRvzL5/OKgRiS9iaGuSkGpTx1ntY9P0DpARIEsf3kye402ZCK YVcU1LReIsyV1wmz9VItwQc0z3NZwF9j6F18rF0150NeRMnsPWu9SyfNDTzhBGxHKR0g +QD5SAlGHCcz/HqQKbg1h23VRyxyCOFv4yaL/Pfmsx3rhjPD2Ac0qCLfwM2KPLg/94ol 6RQa3apuuxFWNQA05J0h1GuzKPecbG2KozQsLENmldqCtED4gKrRyKL20IFcHFa8QCg0 lB1w== X-Gm-Message-State: AOJu0Ywo0VIq+0vz/Y+arW/ExkECaRarOmvzPW/n9Q2UVYBTw7tV36OQ nuAlgYRcsb+gpUDLPcTmSvMn51t0xKvU1UvG9sk= X-Received: by 2002:a17:902:be06:b0:1bf:1320:9743 with SMTP id r6-20020a170902be0600b001bf13209743mr2827746pls.45.1692378757674; Fri, 18 Aug 2023 10:12:37 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 06/33] linux-user/nios2: Remove qemu_host_page_size from init_guest_commpage Date: Fri, 18 Aug 2023 10:12:00 -0700 Message-Id: <20230818171227.141728-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use qemu_real_host_page_size. If !reserved_va, use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson --- linux-user/elfload.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 1da77f4f71..b3b9232955 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1375,10 +1375,14 @@ static bool init_guest_commpage(void) 0x3a, 0x68, 0x3b, 0x00, /* trap 0 */ }; - void *want = g2h_untagged(LO_COMMPAGE & -qemu_host_page_size); - void *addr = mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + int host_page_size = qemu_real_host_page_size(); + void *want, *addr; + want = g2h_untagged(LO_COMMPAGE & -host_page_size); + addr = mmap(want, host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | + (reserved_va ? MAP_FIXED : MAP_FIXED_NOREPLACE), + -1, 0); if (addr == MAP_FAILED) { perror("Allocating guest commpage"); exit(EXIT_FAILURE); @@ -1387,9 +1391,9 @@ static bool init_guest_commpage(void) return false; } - memcpy(addr, kuser_page, sizeof(kuser_page)); + memcpy(g2h_untagged(LO_COMMPAGE), kuser_page, sizeof(kuser_page)); - if (mprotect(addr, qemu_host_page_size, PROT_READ)) { + if (mprotect(addr, host_page_size, PROT_READ)) { perror("Protecting guest commpage"); exit(EXIT_FAILURE); } From patchwork Fri Aug 18 17:12:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714641 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp628206wrs; Fri, 18 Aug 2023 10:13:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVcusUQNzbl3dMCS2HpDyB3hf/rcGKIg7lY5TtK/Cp+p/Box45Sf+L2iTQ5kR9CNdDRUTI X-Received: by 2002:a05:620a:394f:b0:767:27c8:968d with SMTP id qs15-20020a05620a394f00b0076727c8968dmr4088706qkn.6.1692378831699; Fri, 18 Aug 2023 10:13:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378831; cv=none; d=google.com; s=arc-20160816; b=WGTUH1lSbTVv6NA4kwv5tLqKPpPKhSPukOf4N+TsB2XxJEBGyqIkeHxgdpCpVGxPwO jqypsDGGvTVESRBVxL2pO1CcPEuMSqbOzWxzKh1miAFOUErtK4deHmA3L1uT/XLDO5es X66e4HjuVOT/wWXm3alltfcMlWbJjEgVGydW4D4fJ0OBaZrWenySh49mtrKD1IYrjAAe peh5hDKHkUcXB7PmJ29LtJpptsSgYQ/0+2gkEl8kdho7EDSLU93lz8wnodFLFfJO+Ayp svzVNRsKq2sjisfXnZiH1TmczqXbbMB4FX4qV7K9I7q51ztYsfPTuSRmljI1nUw61lOM rkIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=7lc224yrZVrBl3W27R2ZX5OKeL2AGXuP1h02TB+QfsM=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=NyKZ6+pzLsrzSMtWgqG7z03FjOWBLbZQHUTAQFwOpLPNwhNEVypvofrYgb8Qghf/ok RO/QZ6/6BRcBlrg9FWQzPFNq7w35YHQIt6LceqlVdv9jTisLf7KrEcTV/S/ifmdGOW3k y2iRcgg7Jxe6Husbcw25oi4CflcmyYcQvVo4kN3vWlXqbk24LXPLrevVaBBKmBko6Ljr WZFVDuR0pF7eoHcNelp70YezaUF+GfsZVe/pCThWOY3kaS0695MxO48tDUnNnp9WiWSh MS30HLQ0D8mbVBEC/UGqcHbJIExR9dzbtPe56gF1gs3G4zl3y8WSp76MiYpbq+v9NND7 cJLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HEbAU7ya; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h5-20020a05620a244500b00767f7a380d6si1467641qkn.27.2023.08.18.10.13.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:13:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HEbAU7ya; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31g-0008D8-20; Fri, 18 Aug 2023 13:12: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 1qX31e-0008CS-95 for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:42 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31c-00080y-3n for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:42 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1bda9207132so9550945ad.0 for ; Fri, 18 Aug 2023 10:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378759; x=1692983559; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=7lc224yrZVrBl3W27R2ZX5OKeL2AGXuP1h02TB+QfsM=; b=HEbAU7yaoELpANIbWTTid3lkIvGx/UFYBCy9we7cUmYb5FshFV4wDrtyGpAEWiGTer SSFKza2nqZ/7wjUyVi9dIesBdEa9qgcnqHhrVp6eUolgSZNYbdZuBhl5dupftaHdIgz7 P5vlA4FWrPe2Z47zD5vIVvnDRUWlS0mslMHIGIXgn58D+Br5fYWnCS2Qm2VtBY1i3PLo RRk13yF8yJ6wEBKvuyC/WikXKeeauTCSCIrcwMvGXbcHcWU+ZitH1olRN2s0nWZyTj6C f/AVLfOA7RAOlIpO3Rr4Tn5hJotvCgkjf5B/MtVjm/H87yDO0miTRhSNopB4TRryFWgU gqeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378759; x=1692983559; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7lc224yrZVrBl3W27R2ZX5OKeL2AGXuP1h02TB+QfsM=; b=WUnW6/zDv7obHfEFfHjaZACzJpCk6448Bat037E2NH/KyERPJGpOAACluuu7S3xKXr UrlzT3n93O5CDeF/jjW3eB9sBrO7xU+RJIrPP3P4w3hAgK28dmr5WYKFCGCvvGeZSH6M 4uyRpitWbNu0Iku4QGjtZ5dJf07RP9Wd4mjI0zL8CkEf+tWURVOy8Wm66tpDayLJg9a7 VRU8rP9SyPL2DwjrH/Ttz+dtsa1ojOzzrHezadJpMgqeAiz7U5PQ1959OkejmTV0mS2H EPfd17EEnvtfdoFbeEMcL3LHA5D6/KJ240XSSoFbPZFM5jeY2vTseYqcPJ2ZEdNduuYJ eYNA== X-Gm-Message-State: AOJu0Yx61vg64CKixQODj8qwbS+5DKOYZfZA+fN/Fg6t4yC68oBRcAW1 ECjawCmKGWeHLRnOK6XV2Iz19iKYuFL7dnFeftg= X-Received: by 2002:a17:902:d507:b0:1b8:8223:8bdd with SMTP id b7-20020a170902d50700b001b882238bddmr3009052plg.59.1692378758668; Fri, 18 Aug 2023 10:12:38 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 07/33] linux-user/arm: Remove qemu_host_page_size from init_guest_commpage Date: Fri, 18 Aug 2023 10:12:01 -0700 Message-Id: <20230818171227.141728-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use qemu_real_host_page_size. If the commpage is not within reserved_va, use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson --- linux-user/elfload.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index b3b9232955..7963081cd1 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -450,6 +450,7 @@ enum { static bool init_guest_commpage(void) { ARMCPU *cpu = ARM_CPU(thread_cpu); + int host_page_size = qemu_real_host_page_size(); abi_ptr commpage; void *want; void *addr; @@ -462,10 +463,12 @@ static bool init_guest_commpage(void) return true; } - commpage = HI_COMMPAGE & -qemu_host_page_size; + commpage = HI_COMMPAGE & -host_page_size; want = g2h_untagged(commpage); - addr = mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + addr = mmap(want, host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | + (commpage < reserved_va ? MAP_FIXED : MAP_FIXED_NOREPLACE), + -1, 0); if (addr == MAP_FAILED) { perror("Allocating guest commpage"); @@ -478,12 +481,12 @@ static bool init_guest_commpage(void) /* Set kernel helper versions; rest of page is 0. */ __put_user(5, (uint32_t *)g2h_untagged(0xffff0ffcu)); - if (mprotect(addr, qemu_host_page_size, PROT_READ)) { + if (mprotect(addr, host_page_size, PROT_READ)) { perror("Protecting guest commpage"); exit(EXIT_FAILURE); } - page_set_flags(commpage, commpage | ~qemu_host_page_mask, + page_set_flags(commpage, commpage | (host_page_size - 1), PAGE_READ | PAGE_EXEC | PAGE_VALID); return true; } From patchwork Fri Aug 18 17:12:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714656 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp629003wrs; Fri, 18 Aug 2023 10:15:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IESMRwipxF4iaVwbHaPe4SKbz4u9OvwvVnry+BqghB4t5DsH0Mr0CXudiBhEj/Of4i01yng X-Received: by 2002:a05:620a:4485:b0:76c:b0aa:cfd1 with SMTP id x5-20020a05620a448500b0076cb0aacfd1mr4822020qkp.37.1692378907317; Fri, 18 Aug 2023 10:15:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378907; cv=none; d=google.com; s=arc-20160816; b=awb06wPVCsGSzmvYqkWChXjoG2tShA5FzO/pooAPFRXVjTJO4Dm6nN/rtXpYCNQkxb svk7Z881Aa336b6+HM5RXAcyGOpNkf4YhKEPYYaQyUGdbeJjc5AdDmwpE5nAdFkApb29 HaMLMTLE4xNihYSdsIXqLN44bATFb6wsi//uiZOVjJzUfQmyAx4HZx+pdVhEai3SgDd6 FXOQmKF61jPKo8eFrmnfUcJfKFW697DHWFl4ImZxMYwz2Tgwgn1s+SKkz2ZQlr8I4mVk SydngnutHftenugsdLz9af6YJKdHfM6WJtWv572t9ejl1kGxvFFADKZVWzCY2KalyRH4 5qog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=r4oK6DpGgmRt3Rqz8pdIMkWopOhHonW2cpDcnZxadQo=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=WtidUE8FIrjfhSwqDogtutiFx1f184uG+fP4bF0icnQL2uiLfsgABMUGnASuWrTPXm hudRN91YWJfmouwwUgZSFHW36FqzNAy0sKZAuIT+Er7vRUC+sBHs9pdjecHmLkX5ekbO 8N5tmlQt9H+BHtFu5cwgi7HqFFmQpDliuKt+Ruj7e3JYwrb6CppLyS0N2ocs7IaR1/6v UGEotqNaSP/TxHBtGe1uh3Ec51/29i/r8WPSOVVPOJQF1Dw5sGYK2uMWRoIO5qyTKHIE d+xqFTGg1+S4/Ggr8YseRp6itPmteV4MTSVFpWaX1UBAJkmjA6IYJz91j05IUTb6axnj UBPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=t17v3VzB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u22-20020a05620a455600b0076d8ffbd9c8si911906qkp.139.2023.08.18.10.15.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:15:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=t17v3VzB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31h-0008DR-Di; Fri, 18 Aug 2023 13:12:45 -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 1qX31g-0008D9-2d for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:44 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31d-000819-CB for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:43 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1bf3a2f44f0so6376915ad.2 for ; Fri, 18 Aug 2023 10:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378760; x=1692983560; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=r4oK6DpGgmRt3Rqz8pdIMkWopOhHonW2cpDcnZxadQo=; b=t17v3VzBEvWBgj+5+ETfw/P/YztRl07KbnNqEroFLygh+QbpbCmy87pX0eM6mXWHyP 7Yi09x9trcL1zje3Pjbcq+lAog9jDyeEdYLHgxDRr1TemhKn4wtNd9qvnzijtMdjH9jR 20gsvUqpdLlm2gOiRKvKtVxJVvKBZofnIS1I2+y1HEOSSVJ0EliDkmLJ6R7fPX0bxM+Q zE025vupOFv4E8+wWaLLBMsIJJNNs357hmy47Z+/DyAkOeaSO3P77IecCcRaNqigg3Va dI596cAlr2iwFOz0axNxDU59F36LGOMmy+H+GqTAurLS8k++PsEpgQnFPfTr1DEsVxnP mMwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378760; x=1692983560; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r4oK6DpGgmRt3Rqz8pdIMkWopOhHonW2cpDcnZxadQo=; b=Iv0eTSq5sVPAIL+JyxHPeXwUE+tsvqsfkKCmSPIT76yA/EDNAVsx5eCsZCpXDtN69y 0zAWDyZUaJbaDH/sACgfzYS+IfsCtyHBWMXtnslZLoLHZmCqMowbrEZKhDeSXy4ssNFu /B/DZxBUfxuS2+xUFDRr9nhQGAbfpe7sXciC0sqBNVcQfqHmEOCWUgzDXVVRPdWYdo5S 7+hDxXhjS324YFVNUTp1WBrk7l8lwt9TlKIslHwRSV3lZBiYy68Yh1HHEMTsuPVZHEaV 0xtLCt4pvQOVkgoOUx3k0yeT5rnoRmRnhqNxuhxDgkNuNRRsgJEfkjIlhN9bf6euJuMU goPQ== X-Gm-Message-State: AOJu0YwzWNxIXioV+ePQVPkC1OkNrMZ1QW4WFbNDPW4y0DWMMrVB2YFJ WGSgCbJtx6YDqZxnR9s9vV5GS9FmV3NkGo2hn2E= X-Received: by 2002:a17:903:41d0:b0:1bf:25a0:f875 with SMTP id u16-20020a17090341d000b001bf25a0f875mr3579189ple.39.1692378759980; Fri, 18 Aug 2023 10:12:39 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 08/33] linux-user: Remove qemu_host_page_{size, mask} from mmap.c Date: Fri, 18 Aug 2023 10:12:02 -0700 Message-Id: <20230818171227.141728-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use qemu_real_host_page_size instead. Signed-off-by: Richard Henderson --- linux-user/mmap.c | 66 +++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 9aab48d4a3..fc23192a32 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -121,6 +121,7 @@ static int target_to_host_prot(int prot) /* NOTE: all the constants are the HOST ones, but addresses are target. */ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) { + int host_page_size = qemu_real_host_page_size(); abi_ulong starts[3]; abi_ulong lens[3]; int prots[3]; @@ -145,13 +146,13 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) } last = start + len - 1; - host_start = start & qemu_host_page_mask; + host_start = start & -host_page_size; host_last = HOST_PAGE_ALIGN(last) - 1; nranges = 0; mmap_lock(); - if (host_last - host_start < qemu_host_page_size) { + if (host_last - host_start < host_page_size) { /* Single host page contains all guest pages: sum the prot. */ prot1 = target_prot; for (abi_ulong a = host_start; a < start; a += TARGET_PAGE_SIZE) { @@ -161,7 +162,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) prot1 |= page_get_flags(a + 1); } starts[nranges] = host_start; - lens[nranges] = qemu_host_page_size; + lens[nranges] = host_page_size; prots[nranges] = prot1; nranges++; } else { @@ -174,10 +175,10 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) /* If the resulting sum differs, create a new range. */ if (prot1 != target_prot) { starts[nranges] = host_start; - lens[nranges] = qemu_host_page_size; + lens[nranges] = host_page_size; prots[nranges] = prot1; nranges++; - host_start += qemu_host_page_size; + host_start += host_page_size; } } @@ -189,9 +190,9 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) } /* If the resulting sum differs, create a new range. */ if (prot1 != target_prot) { - host_last -= qemu_host_page_size; + host_last -= host_page_size; starts[nranges] = host_last + 1; - lens[nranges] = qemu_host_page_size; + lens[nranges] = host_page_size; prots[nranges] = prot1; nranges++; } @@ -226,6 +227,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last, int prot, int flags, int fd, off_t offset) { + int host_page_size = qemu_real_host_page_size(); abi_ulong real_last; void *host_start; int prot_old, prot_new; @@ -242,7 +244,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last, return false; } - real_last = real_start + qemu_host_page_size - 1; + real_last = real_start + host_page_size - 1; host_start = g2h_untagged(real_start); /* Get the protection of the target pages outside the mapping. */ @@ -260,12 +262,12 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last, * outside of the fragment we need to map. Allocate a new host * page to cover, discarding whatever else may have been present. */ - void *p = mmap(host_start, qemu_host_page_size, + void *p = mmap(host_start, host_page_size, target_to_host_prot(prot), flags | MAP_ANONYMOUS, -1, 0); if (p != host_start) { if (p != MAP_FAILED) { - munmap(p, qemu_host_page_size); + munmap(p, host_page_size); errno = EEXIST; } return false; @@ -280,7 +282,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last, /* Adjust protection to be able to write. */ if (!(host_prot_old & PROT_WRITE)) { host_prot_old |= PROT_WRITE; - mprotect(host_start, qemu_host_page_size, host_prot_old); + mprotect(host_start, host_page_size, host_prot_old); } /* Read or zero the new guest pages. */ @@ -294,7 +296,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last, /* Put final protection */ if (host_prot_new != host_prot_old) { - mprotect(host_start, qemu_host_page_size, host_prot_new); + mprotect(host_start, host_page_size, host_prot_new); } return true; } @@ -329,17 +331,18 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size, */ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) { + int host_page_size = qemu_real_host_page_size(); void *ptr, *prev; abi_ulong addr; int wrapped, repeat; - align = MAX(align, qemu_host_page_size); + align = MAX(align, host_page_size); /* If 'start' == 0, then a default start address is used. */ if (start == 0) { start = mmap_next_start; } else { - start &= qemu_host_page_mask; + start &= -host_page_size; } start = ROUND_UP(start, align); @@ -448,6 +451,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, int flags, int fd, off_t offset) { + int host_page_size = qemu_real_host_page_size(); abi_ulong ret, last, real_start, real_last, retaddr, host_len; abi_ulong passthrough_start = -1, passthrough_last = 0; int page_flags; @@ -493,8 +497,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, } } - real_start = start & qemu_host_page_mask; - host_offset = offset & qemu_host_page_mask; + real_start = start & -host_page_size; + host_offset = offset & -host_page_size; /* * If the user is asking for the kernel to find a location, do that @@ -523,8 +527,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, * may need to truncate file maps at EOF and add extra anonymous pages * up to the targets page boundary. */ - if ((qemu_real_host_page_size() < qemu_host_page_size) && - !(flags & MAP_ANONYMOUS)) { + if (host_page_size < TARGET_PAGE_SIZE && !(flags & MAP_ANONYMOUS)) { struct stat sb; if (fstat(fd, &sb) == -1) { @@ -551,11 +554,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, host_len = HOST_PAGE_ALIGN(host_len); host_prot = target_to_host_prot(target_prot); - /* - * Note: we prefer to control the mapping address. It is - * especially important if qemu_host_page_size > - * qemu_real_host_page_size. - */ + /* Note: we prefer to control the mapping address. */ p = mmap(g2h_untagged(start), host_len, host_prot, flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); if (p == MAP_FAILED) { @@ -621,7 +620,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, * aligned, so we read it */ if (!(flags & MAP_ANONYMOUS) && - (offset & ~qemu_host_page_mask) != (start & ~qemu_host_page_mask)) { + (offset & (host_page_size - 1)) != (start & (host_page_size - 1))) { /* * msync() won't work here, so we return an error if write is * possible while it is a shared mapping @@ -650,7 +649,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, /* handle the start of the mapping */ if (start > real_start) { - if (real_last == real_start + qemu_host_page_size - 1) { + if (real_last == real_start + host_page_size - 1) { /* one single host page */ if (!mmap_frag(real_start, start, last, target_prot, flags, fd, offset)) { @@ -659,21 +658,21 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, goto the_end1; } if (!mmap_frag(real_start, start, - real_start + qemu_host_page_size - 1, + real_start + host_page_size - 1, target_prot, flags, fd, offset)) { goto fail; } - real_start += qemu_host_page_size; + real_start += host_page_size; } /* handle the end of the mapping */ if (last < real_last) { - abi_ulong real_page = real_last - qemu_host_page_size + 1; + abi_ulong real_page = real_last - host_page_size + 1; if (!mmap_frag(real_page, real_page, last, target_prot, flags, fd, offset + real_page - start)) { goto fail; } - real_last -= qemu_host_page_size; + real_last -= host_page_size; } /* map the middle (easier) */ @@ -739,6 +738,7 @@ fail: static void mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) { + int host_page_size = qemu_real_host_page_size(); abi_ulong real_start; abi_ulong real_last; abi_ulong real_len; @@ -748,7 +748,7 @@ static void mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) int prot; last = start + len - 1; - real_start = start & qemu_host_page_mask; + real_start = start & -host_page_size; real_last = HOST_PAGE_ALIGN(last) - 1; /* @@ -757,7 +757,7 @@ static void mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) * The single page special case is required for the last page, * lest real_start overflow to zero. */ - if (real_last - real_start < qemu_host_page_size) { + if (real_last - real_start < host_page_size) { prot = 0; for (a = real_start; a < start; a += TARGET_PAGE_SIZE) { prot |= page_get_flags(a); @@ -773,14 +773,14 @@ static void mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) prot |= page_get_flags(a); } if (prot != 0) { - real_start += qemu_host_page_size; + real_start += host_page_size; } for (prot = 0, a = last; a < real_last; a += TARGET_PAGE_SIZE) { prot |= page_get_flags(a + 1); } if (prot != 0) { - real_last -= qemu_host_page_size; + real_last -= host_page_size; } if (real_last < real_start) { From patchwork Fri Aug 18 17:12:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714659 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp629407wrs; Fri, 18 Aug 2023 10:15:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFhtuYn+uG5gNwohY68FrySA03kpbJpGvr0lqXqrs8YibSBT94ncA1IBPQstnWJBdId6U20 X-Received: by 2002:ac8:5b07:0:b0:40c:58a1:cb40 with SMTP id m7-20020ac85b07000000b0040c58a1cb40mr4363512qtw.15.1692378943865; Fri, 18 Aug 2023 10:15:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378943; cv=none; d=google.com; s=arc-20160816; b=cJI0lwW1lHdgYn6TnbJBztwU3FFnVVI+VDXccLoilVEvxWa+BMKszBqc20CXwjxI7+ bgUoa7l794K7Hkp9dmOG8w5gjY5DP/XwwwoEq7v4GQidELiCg0WAU9s5KRiLLjLHUIlf ZEVGLujkeziMdRLBbIY487BsigTIlYzXVR+nfdrEHLmn+GeT+q2/0NkliiTgjPOcx4gR btp6XfK2/yWWc+rT/tJj8iXkH+JpM/pW+BkVW5NYCud+4xEkDXW1srDdmBRjpMfND7BM OSJHckwTDmF5xWSmCMN84FeU+zeq8OdEw+YIavEjrefW7zcU2zPVGcMWrH/xo94Nzgf7 mxWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=0VhX8uKhISO1+aAbqkSU7fErwJnjxPvu/vXb9fW78xU=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=zsETYWQa3XJHVENREEyvCe6VWarzDBD5DN/+vJTCi9RYUsnkKCRXO+H79Oks/TeXWy gttONiA9E8u9TyLiYERZ7J+pWzNq1hv9jDajluF45okIrlgq41B9osSUqJqHGE5kpm5O 9teafHJBYz8RgUHRr1VJXj8ATpjPe6+F3OrVesHSJ9BcwCl3A8O24JuTxbw3mBfIkZDM FKJNJ+6gvUecef/30mXlu8q+UMPwACqokNuLgYDwghLLH2F0+iZxovNYOpuBWD8hNVLv 5x+JVZdp9aTdzkXhCf6Z00i5gE5C00jjjt8VzcvHaVA7no533IMygV7sbhaGEIXxDOIL iNig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RpA4C2lq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l11-20020a05622a174b00b00405d0bc11f0si1549105qtk.563.2023.08.18.10.15.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:15:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RpA4C2lq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31h-0008Da-G2; Fri, 18 Aug 2023 13:12:45 -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 1qX31g-0008DA-5D for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:44 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31d-00081J-Uw for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:43 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1bdf4752c3cso8537985ad.2 for ; Fri, 18 Aug 2023 10:12:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378760; x=1692983560; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=0VhX8uKhISO1+aAbqkSU7fErwJnjxPvu/vXb9fW78xU=; b=RpA4C2lqWVg+lVV3ks5rrrQFu3awe1dUw9+puCeDBwn8RB7+TRrNbEfNiDbumDWknT T4J5Cd8O+S+gnLNj4SVl99fMNs2bhczfySoM0His4csqMRRYHkjHGgijk+EiOEqyz3jZ GaJ0I3knINgbSf0qhLR7OSuSvtPb5ohKmd9HjFIFqDvLvG3br3UHet0+81lCv5xq7Fvn YioDeCAE1/QpG3YzEzwC+6xmaidFNhyUq5Ea3geZFlErUU2J6B3C8fHNKTQzJrh/vNSv 3p7CYx3fJPijM41kbuz+yTX/+M2b4O//GiKEn0NKWyEdHmt1w6s1krShyMNpXdbS9Szp mZnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378760; x=1692983560; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0VhX8uKhISO1+aAbqkSU7fErwJnjxPvu/vXb9fW78xU=; b=PkRaNo6b3vTRglYwd8PSXqY2Y0MrjfRAFIQakBOzkGaxXNML532Zj1cKEk0ZdvSpuA x4PrXvMiSNdRKIUV2bvQV2CpMrgKvvwTFJBq3GGwQivnVS/GQlcgoy9On/WZ1MXUtKBD bxTVGxkHkRV2PryqjNzXfGfOO0gFlgEmlElSragu0RwtivoS6ZgaV14G222I618XqhB/ +Zn/if/4oA+ndU78dPdfxDMv3SoDZ6VaiwdVx93aWhvMrb+6NKeZppfUkSKevKYpu8Uv 10X5+d0yveFCjKFaOy50EMPurxxmSzizKIwvWyfW9dIazvp+RS/lnA9zRGqIvO9XewKI 0KYw== X-Gm-Message-State: AOJu0Yxw2A6/dxKDXUc0gq1481LDd+SQ/XZbmgs5pxxeTFhHGhFvgo/E ggdgGlYRvpBYYtGCuathPkMV2z44+zbnOIDLF1M= X-Received: by 2002:a17:902:8c98:b0:1b8:aef2:773e with SMTP id t24-20020a1709028c9800b001b8aef2773emr2848273plo.46.1692378760684; Fri, 18 Aug 2023 10:12:40 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 09/33] linux-user: Remove REAL_HOST_PAGE_ALIGN from mmap.c Date: Fri, 18 Aug 2023 10:12:03 -0700 Message-Id: <20230818171227.141728-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We already have qemu_real_host_page_size() in a local variable. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index fc23192a32..48a6ef0af9 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -541,7 +541,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, * the hosts real pagesize. Additional anonymous maps * will be created beyond EOF. */ - len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset); + len = ROUND_UP(sb.st_size - offset, host_page_size); } } From patchwork Fri Aug 18 17:12:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714657 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp629178wrs; Fri, 18 Aug 2023 10:15:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGpQ5htv32om9FSc5RKUMaKD+eAgQ+2LSX8v4+xNrc56xHorUnNhmmGPPzCepjx+MESaREl X-Received: by 2002:a05:622a:1054:b0:410:ca1:62b2 with SMTP id f20-20020a05622a105400b004100ca162b2mr4527169qte.60.1692378921343; Fri, 18 Aug 2023 10:15:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378921; cv=none; d=google.com; s=arc-20160816; b=0AGnZxc4JCMTBwhrOT4VKxT/LPosq4jYWVr7sJmBl00boqmOxQuWSv410iixueovoF /2GYZ04amhb/dugIGdy4SM+fvxuNstAomwQBDQ05P/Usuu0Vd4f0KRYrjykkW6Ph4Lgq 3UChl5CvEajBlU4lHOmb7DJv4tfNBMT1AUG22ZNy0onNNNuCam97iTkTW/4XFLe4DthC 1torqrnLHmmxqXmSjoRNtTtDmFsUfrAleVrWduOdvrSYPOeBVxuOx39w3BwT7At198zb engOR7wKiakOuVrLg1W36XndoeUQdDUYlFpGNEVl5F0RUaBRqzCGb+64+8IhCFDQdBUz RdIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=zm6LGbzRYY77HgezAnXq5Cmr5DPYLmRbQvieaAAbplU=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=gGn3cv+45CXVc5Kbd3da4b4CjYjM/HiJCaL6gF8zIenHHR85gIDBcSOluhrOy/xmzT 1WBq6rBlts9eENKUGIcvereU/HszxpDaMhptvwgykk7pbuEQMkZi9hsgDDB8I2f645GC jRtH5I2bZUoBOQiZv1uXQZn5YsHbC9TKnwXC7b3Mna/ILwa2hpZrvS82lub4M4Iz6n5U exdlJJa96K+mJamTf/Z88IJCmSq5gNXuxfXoUIFymeGdkW35nW81hYlTFQTooTdyEr+4 YHtjdcJ9wCn/B23b5oSpfCym3eSJHTwtjcRy8Z9FUnVz1Uu/8mWLqXc7fCnI31KIIBSn AsZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h8miP2KV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c13-20020a05622a058d00b0040ee47cae96si1490218qtb.621.2023.08.18.10.15.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:15:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h8miP2KV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31j-0008EZ-2G; Fri, 18 Aug 2023 13:12:47 -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 1qX31i-0008EB-3V for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:46 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31f-00081X-TF for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:45 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1bba48b0bd2so8738905ad.3 for ; Fri, 18 Aug 2023 10:12:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378762; x=1692983562; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=zm6LGbzRYY77HgezAnXq5Cmr5DPYLmRbQvieaAAbplU=; b=h8miP2KVjiASi/7WufWnevxrGkCfGySgUm2aRmkUQjL4Ulw/8lN1OEt0ESpD25Ui8H TuIOtlN70v3+sTMzyu6UhC0avpKzMK93Eip6mRh6QouX0vpNomyc4i6B5+aARk2UudmC mn6/lk2s7bpNb4P7wZ2uLDWHvFClI/rjL+pdz2iVgyfhxB+ExXzdHZyWIMnOEvwzJYjz rzGE5MvnEYpDz+/I9herQurC9Gbu84nbYGgnuAfoqCTe2IuGLiNgTtg8dF3IqygDnxnP kiqlfy2B6SYFQj3v0xYiFFh3Lbf++BFZNIaSbIwWbsYrjAAboneBgFEhsdj9eGrQQoDf HFJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378762; x=1692983562; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zm6LGbzRYY77HgezAnXq5Cmr5DPYLmRbQvieaAAbplU=; b=BjNnAeGnDufDnMBVF4Mo/V+c+mahN0CpbJTmXSa2VvTCO0PF86w1+5avWyO/bHzJox XHrcr+1e2hRwrRSelyR9AzFrQPYW3kW+x6SFZhwKKcJv7oVKZHuBbEaNYDjJ2HsJsuWo LU+6b0MD46K8cdoQdZuH+nA/Eeb+YOmq4mSUGF5SMKewnqy4ZTuESprHMFmWJK/aW9VE Kr8VCbh1qv8mgbVbAKrQ35R0K6sAR3Ntjoab1zsFYcOhbcSvBQGCNnhVzJvnHwyH+4d4 KaXpKTpGYmzStLyfwrkjYnFmTjeOWIbr+7vnWdJkd/Z3xMTZAvn2Byc9i1Foz8Q1j82C GCuw== X-Gm-Message-State: AOJu0Yzgvxv5XWIoW9ss5zM0elvlW7SPq1VMlDzN3Ka5jFYvEZlmQRSr o7GqGt7dythGC9Rw5op59AZhZXvdOHfGIoLdQYA= X-Received: by 2002:a17:903:1248:b0:1bb:fffd:63d8 with SMTP id u8-20020a170903124800b001bbfffd63d8mr3283905plh.36.1692378762590; Fri, 18 Aug 2023 10:12:42 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 10/33] linux-user: Remove HOST_PAGE_ALIGN from mmap.c Date: Fri, 18 Aug 2023 10:12:04 -0700 Message-Id: <20230818171227.141728-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This removes a hidden use of qemu_host_page_size, using instead the existing host_page_size local within each function. Signed-off-by: Richard Henderson --- linux-user/mmap.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 48a6ef0af9..35f270ec2e 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -147,7 +147,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) last = start + len - 1; host_start = start & -host_page_size; - host_last = HOST_PAGE_ALIGN(last) - 1; + host_last = ROUND_UP(last, host_page_size) - 1; nranges = 0; mmap_lock(); @@ -345,8 +345,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) start &= -host_page_size; } start = ROUND_UP(start, align); - - size = HOST_PAGE_ALIGN(size); + size = ROUND_UP(size, host_page_size); if (reserved_va) { return mmap_find_vma_reserved(start, size, align); @@ -506,7 +505,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, */ if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { host_len = len + offset - host_offset; - host_len = HOST_PAGE_ALIGN(host_len); + host_len = ROUND_UP(host_len, host_page_size); start = mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); if (start == (abi_ulong)-1) { errno = ENOMEM; @@ -551,7 +550,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, void *p; host_len = len + offset - host_offset; - host_len = HOST_PAGE_ALIGN(host_len); + host_len = ROUND_UP(host_len, host_page_size); host_prot = target_to_host_prot(target_prot); /* Note: we prefer to control the mapping address. */ @@ -581,7 +580,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, goto fail; } last = start + len - 1; - real_last = HOST_PAGE_ALIGN(last) - 1; + real_last = ROUND_UP(last, host_page_size) - 1; /* * Test if requested memory area fits target address space @@ -749,7 +748,7 @@ static void mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) last = start + len - 1; real_start = start & -host_page_size; - real_last = HOST_PAGE_ALIGN(last) - 1; + real_last = ROUND_UP(last, host_page_size) - 1; /* * If guest pages remain on the first or last host pages, From patchwork Fri Aug 18 17:12:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714644 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp628244wrs; Fri, 18 Aug 2023 10:13:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHKRilnCp8MO66GwypiS+z2G/jWf/+hU5QJbtewV+kyb0ZxK/OZHB3faVZN/HilPK7dePhI X-Received: by 2002:a0c:ab8b:0:b0:642:a5da:f0a7 with SMTP id j11-20020a0cab8b000000b00642a5daf0a7mr3692705qvb.26.1692378835341; Fri, 18 Aug 2023 10:13:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378835; cv=none; d=google.com; s=arc-20160816; b=A1S73jBaD1AlxjtwVWCxloO6dx7kbPH+5nZtNXGQnUmiwnADj5pRSeyGdeEbKml+f+ AtAN2jo03G9V3AleOUbjP+NJiLykokslBrKFNSpkmsLy7/04LrzWA4jvHcs1N2Etsi1U 343ZBv7/AEFxsNZAws0daJalC4AYySK8S5XpFf+XdwXVUnGNQmaKAnxlVB35x71cJ7vV ELZKsLSMSIkHexLP2VGUKOVz9+L6R5wmcIIdga52kSQI4NJxmVmsxdwy1ShUWCCATvhm Bc3ehlYpFZrgiQt/VUZS9lsaU6BQdPtcEHyXTzQlreLaZl3tII+d7tMNEg39/ZOmiWnH vT3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=aNsGM1lrXvwjZfK8fzxAwlxZ3vZk+R9BD/kfTxJ1kzo=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=loJpM3oA1SkPHcOf4sTPu9wInJA6rb93jC8UblEo6EX5hGKxeLmdTXbiJUYmFEYsqt UpH0S4H4JrycKEGxNRzkBWdTgU7SdVkQy9RPbpTCk0tS24jqJljMsB2vdcwWmwKXmgUZ lFUWzGM2ECe3Sy062OLuny5zSvtiWMWiwSYZ3+yIHxzHuZ5FeSAmEtFikTpzfzJlzFJ9 fzhJs//NAIiplchdHIn/gkPDZyPDOToTSk7q9tw/0epvUTU5nD7K29TFanqy6vk7koqT GnSWuAQyFDTiW1zVDBJXkn72Vyf3IwSPmKpnKlhWIzhgDHxqZk+qpFicobSvRQerWb37 BFyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QmJnSHmA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a2-20020a0c8bc2000000b006437df19eb7si1607230qvc.420.2023.08.18.10.13.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:13:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QmJnSHmA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31l-0008FI-7r; Fri, 18 Aug 2023 13:12: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 1qX31i-0008EP-OX for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:46 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31g-00081g-Hx for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:46 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1bf3a2f4528so6939275ad.2 for ; Fri, 18 Aug 2023 10:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378763; x=1692983563; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=aNsGM1lrXvwjZfK8fzxAwlxZ3vZk+R9BD/kfTxJ1kzo=; b=QmJnSHmAERh0B3/YwLvWptTFBOT1GwzYcz/MQ0I0LP4S1Fdrw9a3XwuSkpIZEP4jjg ySmkoJbjeQySUYRCxBWse1MC58y9YpXheSgVwfS/D6pGhTPXwylND6hi6PmYN9JanO3V EmOktTv2ut1Ld8QJuefFxUnrNE85Tjg9FxWcAiXJF5VPbjX+t/LoCXqT7NjCH2J40XU+ RcFASXK0NJOypZQlCfQtgGQnyRurj02bUdKSEe0qPd//oQReJhCfQBt6i4aZMa3xoTvI Ta4AVTedtA1sbJAE3g1hLB8g3SO6fvN31i/Z8MwrMlNGuprONkpWzXDp0THk0LP11ZrI 1yPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378763; x=1692983563; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aNsGM1lrXvwjZfK8fzxAwlxZ3vZk+R9BD/kfTxJ1kzo=; b=LvpM4Udn1dnu3mNEa+Wlt47Nay5Gy+yVbM5qRA4g0GMBmyhAp+bPLFfXYRVvYyy5Y5 qkoDlMu9ZeAP+ng3BGzNz+HLqX2bPpl3jWM1LJ38fKdN9w904xgUWV7CdEBQTkkaVgBt 4I8IDMgGyxFWovf88dvAyum3VZKKtUoVq+vd0kqlO8Rn29q7domHO3CHb8WtDy5bz42L U0Vn+2xBuJDDouMAc3w3qT9lzEjMMWYpDdHtFKahGZBcqlV42HNi4MYy0dY6nMT6qeYP oCFMKKEMQDseR0DYmN00TDqKQ6YK2fOwJV5s1nj/aTCIctKwYHBdfvrCF43rPD/3uAzc iquw== X-Gm-Message-State: AOJu0YxaLkiaSdP+fUUvSKJbUN3iLmeAvhvNsiYyKpkQZSkm4/cnpywA 1PHXF+PmZ2VizMoiV2LBYIyqnY+rAqlHrnON+C0= X-Received: by 2002:a17:902:f68b:b0:1bb:9c45:130f with SMTP id l11-20020a170902f68b00b001bb9c45130fmr3064503plg.69.1692378763410; Fri, 18 Aug 2023 10:12:43 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 11/33] migration: Remove qemu_host_page_size Date: Fri, 18 Aug 2023 10:12:05 -0700 Message-Id: <20230818171227.141728-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Replace with the maximum of the real host page size and the target page size. This is an exact replacement. Signed-off-by: Richard Henderson --- migration/ram.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 9040d66e61..1cabf935f2 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3033,7 +3033,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) { RAMState **rsp = opaque; RAMBlock *block; - int ret; + int ret, max_hg_page_size; if (compress_threads_save_setup()) { return -1; @@ -3048,6 +3048,12 @@ static int ram_save_setup(QEMUFile *f, void *opaque) } (*rsp)->pss[RAM_CHANNEL_PRECOPY].pss_channel = f; + /* + * ??? Mirrors the previous use of qemu_host_page_size below, + * but is this really what was intended for the migration? + */ + max_hg_page_size = MAX(qemu_real_host_page_size(), TARGET_PAGE_SIZE); + WITH_RCU_READ_LOCK_GUARD() { qemu_put_be64(f, ram_bytes_total_with_ignored() | RAM_SAVE_FLAG_MEM_SIZE); @@ -3056,8 +3062,8 @@ static int ram_save_setup(QEMUFile *f, void *opaque) qemu_put_byte(f, strlen(block->idstr)); qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr)); qemu_put_be64(f, block->used_length); - if (migrate_postcopy_ram() && block->page_size != - qemu_host_page_size) { + if (migrate_postcopy_ram() && + block->page_size != max_hg_page_size) { qemu_put_be64(f, block->page_size); } if (migrate_ignore_shared()) { @@ -3881,12 +3887,20 @@ static int ram_load_precopy(QEMUFile *f) { MigrationIncomingState *mis = migration_incoming_get_current(); int flags = 0, ret = 0, invalid_flags = 0, len = 0, i = 0; + int max_hg_page_size; + /* ADVISE is earlier, it shows the source has the postcopy capability on */ bool postcopy_advised = migration_incoming_postcopy_advised(); if (!migrate_compress()) { invalid_flags |= RAM_SAVE_FLAG_COMPRESS_PAGE; } + /* + * ??? Mirrors the previous use of qemu_host_page_size below, + * but is this really what was intended for the migration? + */ + max_hg_page_size = MAX(qemu_real_host_page_size(), TARGET_PAGE_SIZE); + while (!ret && !(flags & RAM_SAVE_FLAG_EOS)) { ram_addr_t addr, total_ram_bytes; void *host = NULL, *host_bak = NULL; @@ -3987,7 +4001,7 @@ static int ram_load_precopy(QEMUFile *f) } /* For postcopy we need to check hugepage sizes match */ if (postcopy_advised && migrate_postcopy_ram() && - block->page_size != qemu_host_page_size) { + block->page_size != max_hg_page_size) { uint64_t remote_page_size = qemu_get_be64(f); if (remote_page_size != block->page_size) { error_report("Mismatched RAM page size %s " From patchwork Fri Aug 18 17:12:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714650 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp628510wrs; Fri, 18 Aug 2023 10:14:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAaOlupBUdstSeS9FIBTQxFnRc0MjB5dGKbjYKVWOWVXbqsq5XV8svnom/rWa3mGPqwE/h X-Received: by 2002:a05:620a:242:b0:76d:4a15:6f53 with SMTP id q2-20020a05620a024200b0076d4a156f53mr3285437qkn.25.1692378862342; Fri, 18 Aug 2023 10:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378862; cv=none; d=google.com; s=arc-20160816; b=EOLa1Dci7QKwyoAPI3VuI4FKFUczDbBy/RLkTlAUd0lT6SFyLWp4aeq93EMS3KiBfH RL3vqkw9rImmLjn5sPc0qOjiuI2pUrBerkM/eFKTI2S+43wcealHOMf8b2+iIbbj6gkZ rLsK/LgIgQs6NQWiwbfOfL8lqt0w72LXl3LEm9rpvOMuXs7xZz7wsqHBtcY4r1kcxMZq 952NhH/TdyhAC7Egi2wfQfVTxm1THvzR/7az08ITCN/c68gcqhn0EOnSfibMH8d/nwqV MYgUro5kFoE+8c28V4qFkWsYpOPtqS9Y9LqBZBHO/S4QczDGFD55dEgrtVDrcdwukRR5 tH2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=jBDFYDN4txkYXCl4MK4JvDX5trolAszB5+TZawsyMV0=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=l4wHtZqhXwcwYxJSKUNb3cl1/M2Uf6hUazRkOwoTb6KU4fP0vaDlwRap2azgrdopsO NXW/m55S4THjpKCMfO4sAJCYpuPz/+CZNgLEaSCOcLwU/JbdFEOG63qVZBTWgPWnazp5 DcoCRv7eF2h2KcCcDPzonlDubCWy/CI8ZluzXz3pKQGuGpSp47YvucoxXn7nZtkBWQKC zpPoqqCz8L9Ws8H1Lae2js3P0qJoWRACt3cBVlvrcDVwr8cOHEOppC9edwT4n6T0BYms 7yEyD7HncW4mo4tu9AxuOJ31OUqKC5dPjUQhIFAWt77h9Ryaif/hddNXNj6X2PJ3E4rz 9kDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pxt1d9D+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bp11-20020a05620a458b00b0076c8d5c1aeesi1413767qkb.551.2023.08.18.10.14.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:14:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pxt1d9D+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31m-0008FV-1Y; Fri, 18 Aug 2023 13:12:50 -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 1qX31j-0008Er-Rj for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:47 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31h-000821-PS for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:47 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bc73a2b0easo9420435ad.0 for ; Fri, 18 Aug 2023 10:12:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378764; x=1692983564; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=jBDFYDN4txkYXCl4MK4JvDX5trolAszB5+TZawsyMV0=; b=Pxt1d9D+XP0sFJvyHYNG15isOnN3taKco+vzi1yxM43rFgGnHIosqnwtOR+EcrzM1m ZxrJ4+LEbtN/H7B1Ih4SoLJXwyK3TtA8AD+M0JkqvGZZNfLE2ycs7uUMKgkygN1kDk1b xR7BIA6BEfIxZBXae6edvUDWQZEKOqk2XsrYWXJPkL+5ObdblBWLF0YsJJLTEopCo8Fn 9d4C7WxHMu6pKjUIWvz77Yc3PGzwAornGG9VLg+h3r5IfJgn6TgJLRWZehWNHspFROTn G8OxC9PWJhn1X0rAKSatvDAqfl2JvjURvEnwt+CaGi34H4wQLVUHho99AV07mX2kiayq rGtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378764; x=1692983564; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jBDFYDN4txkYXCl4MK4JvDX5trolAszB5+TZawsyMV0=; b=YmRn8jFoXslRGqEd0bx+QFf1oRx2/zSv5eVQgx55ghquG2/VbRb6itVS0ZyReZdUxx sPlG38ULF+ISaezHbktZTDQK7ngcAlq3ZRaX0RlAooiz6AoK2Jux3DWbt0gump8TXyOr OLLd80LzOrWzfn+wor4RQ0nJCguN3T38yM8V2ZjBxDWGs4XllvUz2Recj5Q5AMPVt5SX W/10HbHdV/nvoRFLtvBlZCLCWzNExMhTJA0P1g1ZXvkBL3CsZz44m8xDpG30FbCy7qq+ 5gXpBPrppm4vxHMT3k19RDjP1yWAFwI1VhNEjXAIKC4GwgVvM0sqTzRTLneWH5HXeQPn eUfw== X-Gm-Message-State: AOJu0YxnZfs4Qflt4A/12uALdKdlP9Hzh6OP35JZpHgbzCmXyv4nWEx3 8K11ojAWKUWGpkz1rjxBhhatNbdOvimg1JwQOn8= X-Received: by 2002:a17:902:d904:b0:1bc:25ed:374 with SMTP id c4-20020a170902d90400b001bc25ed0374mr2911066plz.49.1692378764559; Fri, 18 Aug 2023 10:12:44 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 12/33] hw/tpm: Remove HOST_PAGE_ALIGN from tpm_ppi_init Date: Fri, 18 Aug 2023 10:12:06 -0700 Message-Id: <20230818171227.141728-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The size of the allocation need not match the alignment. Signed-off-by: Richard Henderson --- hw/tpm/tpm_ppi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/tpm/tpm_ppi.c b/hw/tpm/tpm_ppi.c index 7f74e26ec6..91eeafd53a 100644 --- a/hw/tpm/tpm_ppi.c +++ b/hw/tpm/tpm_ppi.c @@ -47,8 +47,7 @@ void tpm_ppi_reset(TPMPPI *tpmppi) void tpm_ppi_init(TPMPPI *tpmppi, MemoryRegion *m, hwaddr addr, Object *obj) { - tpmppi->buf = qemu_memalign(qemu_real_host_page_size(), - HOST_PAGE_ALIGN(TPM_PPI_ADDR_SIZE)); + tpmppi->buf = qemu_memalign(qemu_real_host_page_size(), TPM_PPI_ADDR_SIZE); memory_region_init_ram_device_ptr(&tpmppi->ram, obj, "tpm-ppi", TPM_PPI_ADDR_SIZE, tpmppi->buf); vmstate_register_ram(&tpmppi->ram, DEVICE(obj)); From patchwork Fri Aug 18 17:12:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714653 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp628754wrs; Fri, 18 Aug 2023 10:14:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4eIJsZ5mm+dh1Bibu//rexKT9lah8w2U4D+mBPtXpQFkm9+TQusWlx3koBk/YOsu52Gt1 X-Received: by 2002:a05:6102:c4:b0:444:c7fa:1aad with SMTP id u4-20020a05610200c400b00444c7fa1aadmr3779066vsp.17.1692378884901; Fri, 18 Aug 2023 10:14:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378884; cv=none; d=google.com; s=arc-20160816; b=N9awon7WH9n8dQoKK5ZzOGYSTeYbggtkiQR9aqEn/DnPh7dH9MHk5eWFAw/EjeDcLh HU908DIrXQbmXTAR5L0tRStVrqnlpPzyIaAT8cjUlJlZ3H6O5ULozulojjDIS4I1JWJZ 7Y7zxD/fDzDiTJsHEsjjb1J+i4QTzMcE29Rm+zO/1LO9pC+/UFbyqA6qmatAtQRvmbwY puoOAEWhkRALiDhE+kXVnr7lcWyy9485H45P7KRCRJ9xyD6ywMmGOvC/aHNLGULR5LBL 0WmOB0yyXhlnlX04+xry6aKHKiw+umeUeAGdxL+xax6NrVkggtdpIqEMS3r22KO8Z0gI TgRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=VPyTBROSdONEOHmOwoKlD5YWMd2vd+yZCLBm/BBj1es=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=FFoEAWZwB382jtMX+XB9eCucbYnvywcCe6wsNae6zWJMXvY4ieP/Lj/DjKAt7olyLn UtakEFvKRxzVeFBvCqPj3sIxRvzEqNAPGNeFEa5tpdoPYHmgcupcwN3EbtSE9OwXjLZE TXy5aNktSb+GsxW3TeP2xMuqZW/5l9OTdnIPaMJ6vznQ8c9e3rC3nNy8NIn01gcERtoQ HqN4z96IB7MKkmPnC2MeqpeGkImW6o6o9OqBUa6Z25iwvqBv9igHFBCFMB0Zapf0L0LU 1pnCCdu5VQwulWiiEwHqGmeRFM6t0CqABFjdyrm17doWirSOr0/P9cyEfwFHQIvZSfEx I+jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=opMjJ9ni; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i10-20020ac85e4a000000b0040354d7e33fsi1569779qtx.87.2023.08.18.10.14.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:14:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=opMjJ9ni; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31m-0008G5-Pw; Fri, 18 Aug 2023 13:12:50 -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 1qX31l-0008FE-0P for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:49 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31i-00082U-UU for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:48 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1bee82fad0fso8783225ad.2 for ; Fri, 18 Aug 2023 10:12:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378765; x=1692983565; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=VPyTBROSdONEOHmOwoKlD5YWMd2vd+yZCLBm/BBj1es=; b=opMjJ9niRwLnvknf2vtrfjkO4b69llRXHvsFi8eORMeRtB44tZ21JWH+GrCeL8onSr WzYdpTZTKnX0bA2UxLX8HQoY18ZhYKeGW1GTPMgul/WbyKGh4HIIxePlMW2S6+yUQdi2 zYdeFzUhZVmNJRGkSICSuZ2G7/og0aHB45BtCa4zq/VmWsbvNKjQVnfXgyEp+ItdPO0m hHGdd3IuATE9yRtsfUFqysLjDb6Si1xncL8wAh1vY6pt+mJXPThuXLZDRuNxGbFzpJ5K eFW5SXQdwiQ+oE2DQBZsIwN+4R9wsDf5lWyrXk27L11hTWDM44HX3zxJ+05wtTmh80An uNLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378765; x=1692983565; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VPyTBROSdONEOHmOwoKlD5YWMd2vd+yZCLBm/BBj1es=; b=CwL2l8BpNxBWmYNYzBa9DSbFC6nVI+0jfBKO0vm61jLFm+RkvpERr4jFQsEe+XiMnT oeYo9r5wUFLbLtP5K+/gSzJzU+slQw54+/7wN3MIl0JFFWWFH3g7BOzR/mRKdNTIYirT FG+T7mb0/umNW3fU01c6BRC7GTtkntYNoG+Wig44VGTgLpVgWljKIFHWLgPofJt5mrI1 pKDKuoldpg+NjoPGmkPFO9KI2OKl67ZunsX0ez/7JFlmOdEjr4JG6mb4YvXtUvq7Fu/f MAsYxVgENVDMk2BygAmJpcvcRNuRCYpTWnfzhxM4opCPl3MthqHaLdUW5LYxcIyoRKpk u+Iw== X-Gm-Message-State: AOJu0Yye/ZPoOeyPX7HRb/JVdGiC4paRr6/iWBRNpkbsRac0gQY6JinS yDaXcC3raOXPfsRZrF2P2+OzKUTKw5mQBc+b5P4= X-Received: by 2002:a17:903:124b:b0:1bb:c87d:7573 with SMTP id u11-20020a170903124b00b001bbc87d7573mr3510483plh.46.1692378765355; Fri, 18 Aug 2023 10:12:45 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 13/33] softmmu/physmem: Remove qemu_host_page_size Date: Fri, 18 Aug 2023 10:12:07 -0700 Message-Id: <20230818171227.141728-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use qemu_real_host_page_size() instead. Signed-off-by: Richard Henderson --- softmmu/physmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 3df73542e1..6881b2d8f8 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -3448,7 +3448,7 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length) * fallocate works on hugepages and shmem * shared anonymous memory requires madvise REMOVE */ - need_madvise = (rb->page_size == qemu_host_page_size); + need_madvise = (rb->page_size == qemu_real_host_page_size()); need_fallocate = rb->fd != -1; if (need_fallocate) { /* For a file, this causes the area of the file to be zero'd From patchwork Fri Aug 18 17:12:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714670 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp630219wrs; Fri, 18 Aug 2023 10:17:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEe+vGZs1W4z3cDZEOvsie4xBjm4TKwtgn8i/P1Dv/oYMTKZfOYU6nJVPbYzjRmM/RtjDD4 X-Received: by 2002:ac8:5789:0:b0:408:59c0:8824 with SMTP id v9-20020ac85789000000b0040859c08824mr4224753qta.62.1692379020055; Fri, 18 Aug 2023 10:17:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692379020; cv=none; d=google.com; s=arc-20160816; b=zanyYyaeIrEjP/obKLfGr4YMsn5U4/c4tsIOu9HUWxDXrSAxvd7PDmVI1csAWArDhl ew17ROQkMB39dcCZYZCIxHUEqXjbMMBVC5qWXUDV6JGmUyCkj63xi7c6J6RUQ1RaWFG9 kpqxh1mdRrA7fEdkW0sGvBcuh65Jpb9Cxdz52GOxe8Ka6xrjBBOO0RuIga90ImGQXorw fgeg0jmje+RM6lgHkalBvX6K/UDamaK5jdcYFTH3/Oi6DdtgHYqMQAOfqwsd4orr/ZXG LZzDyn/TqTHuRzLOjj2MZp5UECybqgXQGoqOHXDsQiNJXKUvXDIyaqiYhz2Kue+il1CF nHUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=phk7XwZ3loE8OzD2nhx9Jjjs9VBjr33DTUu15m85L0s=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=zzHzN2+/Ijt3zXoWvlZyPRXbLPtmtANySH2yOeqq7pjFRdwOSbCmao0d9XBKAKVOJU ekUHasbFHm7SXRCszdRAj0kiiwYyNiqMslBO9LpLVO/wM6VjMLVL8bm6kmRQgBMSOe3q crxmEX/Rn1TvTpUuNXTm5mLhxb7Y2LwnArFbZbQD4MNGN+dKpNZ/L/wZA4P0HBmNwUZ7 dx6oCTX23ZPJVLD8jvhhw+OwLDq5lCb9gxGZOlCw0CdnRHEB5X4CeB97yV0/dwqWYk18 B1lR+4kbSQIBcdoN8RaiL21mj0pKU+n0kMZpsEkmqWyFCMArKurYKmkygYGgfgPAjWo/ sb/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pzBQbICf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n6-20020ac85b46000000b0040fd2e64abesi1510918qtw.342.2023.08.18.10.16.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:17:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pzBQbICf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31n-0008GG-Av; Fri, 18 Aug 2023 13:12: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 1qX31l-0008FN-LU for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:49 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31j-00082k-GM for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:49 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1bf078d5f33so9352135ad.3 for ; Fri, 18 Aug 2023 10:12:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378766; x=1692983566; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=phk7XwZ3loE8OzD2nhx9Jjjs9VBjr33DTUu15m85L0s=; b=pzBQbICffpBTjLzFhtAIXe1forkYOxCZ8TuDl7etFvIYCDsiAkuXE2JbwUq0FI5Md5 kP9f1H8wJ0DV2ZJd/95Yi4vsv1ctPbhV/pWhBZZmRPAgnKYUu0bf+tiprKPI6qcJJ4sA LDXHFibTAZHyW6eg7woYDcLSylriliVW9xeWnxYi4TSrvKXF5slKGuaQ6pTdIaSxred1 svCWEmtYwOnwbfZvIx1L7TtIfhoJR6IxWwP7yXWlGJE5igeMMWjjMME7V1ohlklGjD1u JlxF67pVnxiSh/jGJ+uxqDPi9lGbiLuCZk3qRJuMwOkjP7kJWVWpuF3XrDsqlWteAEst zCUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378766; x=1692983566; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=phk7XwZ3loE8OzD2nhx9Jjjs9VBjr33DTUu15m85L0s=; b=KDYKigRaI0u/2vajnxrPYzKHQnwFRut/NTmOfpBgMsXlQaGszvkQEPjMvfSlTrgkUe zFMD4E1KIn66a6MU06oWAuBL1cRapqTghpiX5YD7CZQuP8n8PzF3zPIbqIa6uf5jn3s6 a+JRyiWJ7Yjn8zy3RcF1X0rLiiN3531e2h7IVSKOjbxiLfAMK5qjs12+Em7rBIaLxOEW 1T59FrFjmSHtepRQ1M/wNZ9HjXrOnj36Mt+GFaYd8KP4KCARqVs3kTa3emJUJLn51oiR 9yo8mYUNAApsNuLNecz5PkJ45JtZO4Ic9a8DQy/z0Rm9dzS76jVL4CbDvT7Oqh0jsMs2 shbw== X-Gm-Message-State: AOJu0YzJ1mzPaWTPUvWXW1qAKKD3FlGl0Ze2ikqF8hDH2sfO+mcaIsb+ NVhl/B5JrVfmz/JY8mtJ5cp8EEmp6cwYfu+HCVA= X-Received: by 2002:a17:903:1ce:b0:1b8:76fc:5bf6 with SMTP id e14-20020a17090301ce00b001b876fc5bf6mr4406214plh.43.1692378766311; Fri, 18 Aug 2023 10:12:46 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 14/33] softmmu/physmem: Remove HOST_PAGE_ALIGN Date: Fri, 18 Aug 2023 10:12:08 -0700 Message-Id: <20230818171227.141728-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Align allocation sizes to the maximum of host and target page sizes. Signed-off-by: Richard Henderson --- softmmu/physmem.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 6881b2d8f8..9eff0acb2f 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -1663,7 +1663,8 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp) assert(block); - newsize = HOST_PAGE_ALIGN(newsize); + newsize = TARGET_PAGE_ALIGN(newsize); + newsize = REAL_HOST_PAGE_ALIGN(newsize); if (block->used_length == newsize) { /* @@ -1898,7 +1899,9 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr, return NULL; } - size = HOST_PAGE_ALIGN(size); + size = TARGET_PAGE_ALIGN(size); + size = REAL_HOST_PAGE_ALIGN(size); + file_size = get_file_size(fd); if (file_size > offset && file_size < (offset + size)) { error_setg(errp, "backing store size 0x%" PRIx64 @@ -1976,13 +1979,17 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size, { RAMBlock *new_block; Error *local_err = NULL; + int align; assert((ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC | RAM_NORESERVE)) == 0); assert(!host ^ (ram_flags & RAM_PREALLOC)); - size = HOST_PAGE_ALIGN(size); - max_size = HOST_PAGE_ALIGN(max_size); + align = qemu_real_host_page_size(); + align = MAX(align, TARGET_PAGE_SIZE); + size = ROUND_UP(size, align); + max_size = ROUND_UP(max_size, align); + new_block = g_malloc0(sizeof(*new_block)); new_block->mr = mr; new_block->resized = resized; From patchwork Fri Aug 18 17:12:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714646 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp628376wrs; Fri, 18 Aug 2023 10:14:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7/M0kSx88J3vyiEDfgRxD8TMYX0H+0Idj964JcXn1Q+kf7ImyxeJ7eRwKDiqjUhxNSu1X X-Received: by 2002:a0c:edca:0:b0:649:1690:57ae with SMTP id i10-20020a0cedca000000b00649169057aemr4010098qvr.16.1692378848838; Fri, 18 Aug 2023 10:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378848; cv=none; d=google.com; s=arc-20160816; b=XLxvZ3xQxcCCEf4tEYWmnf+NWmZUsQTbW8Rft5hiJt53i+71t95Egxw0rnQkmpp0G/ fjl1BsM0tyiVdjsaF0VTBImKikAuIewVLvwwUBXykCud9wRx42rDrf14JDG73HyKdBrM 8Pu6LtF19BGC1fluv+LzZ6/3vvJntEQLZ7kvuRD4mFTcobr6TfiV2nGfFFONlvV/a5IH 9OVKQnoaQGxi90hKSSDIBl5G1PpiTvBLy7MII4oh6HWjwWEaax2EnUspWpDshDguRfFE yKi9t4xKrmm6ALQaBokAW0cu+DymDvvHwwlGejc/arHaT4n6JAA0gmQrJCPbLt26L2dQ yGQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=LMSfIZM5KDQOW8rzGrPmwonqS4UNbZW6sqmCOtQy3AM=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=unx01Zyk+gESOLN8Y3RXpst9wBEMpjLHMpfazYbY1GiaoT2TmQ5DCuzNfNz6WPIsSE G9i6rVCtLvp0a7sQBh2Er+cCyg8+b5rqSzP3O/mcYDv/Fd9QgOJJjCHadCfdgfpCOCNq T+FfszDbPWXMG8J2MFTG8bXBYZYge4UIXKtEGiRSslnVADM9LFdBqVKPfwlVg95oGYpJ mWRTzqloYqRVa+koKlU3YqeWFZwLWzZ+fpdyiCvItGYdQPGvf0zgfN64cpIgjz3rH1t6 nHS2DXDtK5nRVJnBPaiRjQmPD7CYT11lT8alQIMuJufNtVIZCOg+2Q+BWtCqejoxdTRk uR1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bbenPueQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q9-20020a0cf5c9000000b0064c224027b7si571583qvm.269.2023.08.18.10.14.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:14:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bbenPueQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31o-0008Go-Va; Fri, 18 Aug 2023 13:12: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 1qX31n-0008GH-Cv for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:51 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31l-000835-9e for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:51 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1bddac1b7bfso8300365ad.0 for ; Fri, 18 Aug 2023 10:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378768; x=1692983568; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=LMSfIZM5KDQOW8rzGrPmwonqS4UNbZW6sqmCOtQy3AM=; b=bbenPueQefXEXb0zHbO023NAAyRmFlmrOWeqTTddXHSnZeEXMXEIBx3rg5UFaDLuJm BNQ0UAtI6aUD5Qf1gxD3eoVIidcyND5HBh3a2uqSPrBYxdv2KzWz+z3uPm9D7YfQ0hLU mZxAAcmuXrKoid3gIUX5j+Yxjz7mJxDVQpThyez0c1lA6v0QsQEyFPWy6e72PMrOPZ81 /UXOpTw/s4A42ffsJAlDw2Gt8HVid4prqiKBsU9yCZQWmLGQIx3iTtQ5NkRqdmE6qqkD qh5Wvc57uJ3tlx31zc8DOVKV2vXQG5P91HcNgin9hAG4cHkPRkp1l7mEEfZSCn+/JAXK 2osA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378768; x=1692983568; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LMSfIZM5KDQOW8rzGrPmwonqS4UNbZW6sqmCOtQy3AM=; b=cWH46Q8RI/nC6vlXuQpp8LUm/g0jFy2Yd1EOFZjn3IxHl3cTenM/MNNMzTqEPXGITN sbMG3MkN6TuQ3TKXp14E0YTodWdbbZDhcnB/PirQ7jSmQZWPenlSeF3QAljHSuHEvvNw Bxe5i0I7QyEn8+4G6xJqvpxMyRW+p1rY6992UJMOFL9Njab+1djH9xGMlx1M5tYQ46oV MuZJ+qwFQlt7jc/+eYPJJaoBR86GHEtXYvb1+tHvQdXSNjDTHWQtM8ooomHD/O4/vPix 474yIlZh0sSlw3g3+lU4j8T+2idIftVdQwhoiVrH3nXaIgC9YL71yIt6IzaEbhCP3ufl Gq1w== X-Gm-Message-State: AOJu0YwPMwC5Jof/BgPGapTLO7eRfpNiHMCF/fen4wHnzA25bEgohym3 yFEQ86TZH30gyAJpPj3ROvsC9wfRSSQSJJuqFwk= X-Received: by 2002:a17:903:1246:b0:1be:f37f:a8d5 with SMTP id u6-20020a170903124600b001bef37fa8d5mr9210346plh.10.1692378767835; Fri, 18 Aug 2023 10:12:47 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 15/33] linux-user: Remove qemu_host_page_size from main Date: Fri, 18 Aug 2023 10:12:09 -0700 Message-Id: <20230818171227.141728-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use qemu_real_host_page_size() instead. Signed-off-by: Richard Henderson --- linux-user/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 96be354897..c1058abc3c 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -783,7 +783,7 @@ int main(int argc, char **argv, char **envp) } cpu_type = parse_cpu_option(cpu_model); - /* init tcg before creating CPUs and to get qemu_host_page_size */ + /* init tcg before creating CPUs */ { AccelState *accel = current_accel(); AccelClass *ac = ACCEL_GET_CLASS(accel); @@ -806,8 +806,10 @@ int main(int argc, char **argv, char **envp) */ max_reserved_va = MAX_RESERVED_VA(cpu); if (reserved_va != 0) { - if ((reserved_va + 1) % qemu_host_page_size) { - char *s = size_to_str(qemu_host_page_size); + int host_page_size = qemu_real_host_page_size(); + + if ((reserved_va + 1) % host_page_size) { + char *s = size_to_str(host_page_size); fprintf(stderr, "Reserved virtual address not aligned mod %s\n", s); g_free(s); exit(EXIT_FAILURE); @@ -904,7 +906,7 @@ int main(int argc, char **argv, char **envp) * If we're in a chroot with no /proc, fall back to 1 page. */ if (mmap_min_addr == 0) { - mmap_min_addr = qemu_host_page_size; + mmap_min_addr = qemu_real_host_page_size(); qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=0x%lx (fallback)\n", mmap_min_addr); From patchwork Fri Aug 18 17:12:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714647 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp628392wrs; Fri, 18 Aug 2023 10:14:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7I2cLrPq6R48qMoU1UhfmYsnTmpJm9klcTL5YqdGxZTl3+5PkynhF37wM/OSg8kOpCjA0 X-Received: by 2002:a05:622a:4d4:b0:400:9c4e:2abe with SMTP id q20-20020a05622a04d400b004009c4e2abemr3817813qtx.13.1692378849868; Fri, 18 Aug 2023 10:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378849; cv=none; d=google.com; s=arc-20160816; b=lBU+wds9zcsnx3aWE0iwhYvttPbxrQHMU7ARmqovM/HaI3hvnKwb7e3xQV/2/7xQ3l T+DA0VYgAVRWyE8m2NzvlTwI/moGx0k/B5AqiyRuzPLVKIIcfllaGIBUFNxVw7nQhBXF vPCZB34CJUQNnszu3yC5otfYpkYXJrThq8gxyp4Pe9mnCUaIdMB+XDjulpZ63IbKs6eA XUK5Rl7z9ADn2v6f8L0bzhsTA5DVnMBsa3+dX+uDRiSf1BEp7H2NgWdyTUyMLkzICgsS rMVkmU068SPhinfHR1xWwKzHX9FcLGValVYS575YMe/PH16VF9+GHLB/qHrSapQCwHOg hKPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=m1beAKqAHv3vWel3I5O47E14cIOUPK0xwqCuArIxTEk=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=b05XxQjdf2prHvhnk5MiVJnneKolSI9wntNfewHIj1R2aLPs0zdVlhl0kyY3c36q3c KyxQkT0OqkpUNV8eRUqz6uq80FM7QPkotzyC4YVRDNZa0Vy0Y3tgfA6Iw7Quz5HXU38H Ah6cF5Ex1zQrWUc+fqoRTV1ypDCOcaLzwyD27RpGjarjMbmKfM1RJU7u4aojP/Lbd6Vh QmvIHLlTU/Ot/IBfIL/OUZiBPGRe4ToORR5dmwilBc2bALen4q7YiqK9vsCsjN/GA6Ju WsuUzuCKxfMViv5df6NWZU8Ere1gMTQcan1fcPxJM+HlS8PmNnhn0Xb+K2HkcJvubRys 1d/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gzxEpCqu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c6-20020ac85a86000000b0040fe32ab0b6si1549017qtc.286.2023.08.18.10.14.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:14:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gzxEpCqu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31y-0008IV-GF; Fri, 18 Aug 2023 13:13: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 1qX31u-0008HJ-Fu for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:58 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31q-00083b-Mg for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:56 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bdca7cc28dso9452205ad.1 for ; Fri, 18 Aug 2023 10:12:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378773; x=1692983573; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=m1beAKqAHv3vWel3I5O47E14cIOUPK0xwqCuArIxTEk=; b=gzxEpCqu/uMl8lqD7ANQxJlwVKZwmusxGyECuX79n61zlQMN3ByQsWYyxjWjqSG/C/ yNYlNtTeZdBHFqhN5t+gj3hKJTVRy02VAU4dwgILfXdANFKpcn3377yNKRA/3Oyn7Net SLtpLE8+tna0EOGP9reRYVQ9LJyfoI3urKe3l1e6foSIq+8rRf0g1mJzKwInyW/IT0dy 8WxGWHFv98ufPk7xPXfVM5hmlsTrHE4xbupl82qPpMq5+PG8wf6w4M8CpcEC0OGFAYQC h0JeqGbeensrajEt9qduIAIADw4u0/AZrgeTK4oz+JxwDchpboj22sCcgLjYK5IAS7X+ wOJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378773; x=1692983573; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m1beAKqAHv3vWel3I5O47E14cIOUPK0xwqCuArIxTEk=; b=EOK2/HKKHcWWdDFwTEHQJ8cN/vA89Vr5kF6IgnSj/13/C0DirfxeTVZ1rXahNQRCmK RMZe+XvqJ0UpHcn7PmCsj4pugL/y8NhxA6T1LUhCZf9ZvVodvigGWt1MYlZKyZ83wE8c o485YVMLSjh05U5KoUWk0ycYHbW2kfEdx5LzVpNaGe0ZGfDti3bR5jLufIz6ZMb5+PXq Pg/R4JuRV3aUC+5GPqvplN03ykvVMblQnoH6euZp9UY4wrIlVb+4wUH6+Wry5PW4UaFw Kk8U43NS/hmHSSXQW+NXds7+0zLmvwaQD2kGupNoD1lNrCWcO2I9x3j5LZqFZSqitFod /4qA== X-Gm-Message-State: AOJu0Yy40/YVX/boM9Cl5KV2TSLA74N6UokeSQnxklJB0Ird9Xhg/W2L 87Fap+9H81RyDhZYl5sZQIpzA2jrKtodMWR/+54= X-Received: by 2002:a17:902:c155:b0:1bf:728:7459 with SMTP id 21-20020a170902c15500b001bf07287459mr3223402plj.63.1692378773259; Fri, 18 Aug 2023 10:12:53 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 16/33] linux-user: Split out target_mmap__locked Date: Fri, 18 Aug 2023 10:12:10 -0700 Message-Id: <20230818171227.141728-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org All "goto fail" may be transformed to "return -1". Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/mmap.c | 62 ++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 35f270ec2e..448f168df1 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -446,9 +446,9 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) } } -/* NOTE: all the constants are the HOST ones */ -abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, - int flags, int fd, off_t offset) +static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, + int target_prot, int flags, + int fd, off_t offset) { int host_page_size = qemu_real_host_page_size(); abi_ulong ret, last, real_start, real_last, retaddr, host_len; @@ -456,30 +456,27 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, int page_flags; off_t host_offset; - mmap_lock(); - trace_target_mmap(start, len, target_prot, flags, fd, offset); - if (!len) { errno = EINVAL; - goto fail; + return -1; } page_flags = validate_prot_to_pageflags(target_prot); if (!page_flags) { errno = EINVAL; - goto fail; + return -1; } /* Also check for overflows... */ len = TARGET_PAGE_ALIGN(len); if (!len) { errno = ENOMEM; - goto fail; + return -1; } if (offset & ~TARGET_PAGE_MASK) { errno = EINVAL; - goto fail; + return -1; } /* @@ -509,7 +506,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, start = mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); if (start == (abi_ulong)-1) { errno = ENOMEM; - goto fail; + return -1; } } @@ -530,7 +527,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, struct stat sb; if (fstat(fd, &sb) == -1) { - goto fail; + return -1; } /* Are we trying to create a map beyond EOF?. */ @@ -557,7 +554,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, p = mmap(g2h_untagged(start), host_len, host_prot, flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); if (p == MAP_FAILED) { - goto fail; + return -1; } /* update start so that it points to the file position at 'offset' */ host_start = (uintptr_t)p; @@ -566,7 +563,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, flags | MAP_FIXED, fd, host_offset); if (p == MAP_FAILED) { munmap(g2h_untagged(start), host_len); - goto fail; + return -1; } host_start += offset - host_offset; } @@ -577,7 +574,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, } else { if (start & ~TARGET_PAGE_MASK) { errno = EINVAL; - goto fail; + return -1; } last = start + len - 1; real_last = ROUND_UP(last, host_page_size) - 1; @@ -589,14 +586,14 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, */ if (last < start || !guest_range_valid_untagged(start, len)) { errno = ENOMEM; - goto fail; + return -1; } if (flags & MAP_FIXED_NOREPLACE) { /* Validate that the chosen range is empty. */ if (!page_check_range_empty(start, last)) { errno = EEXIST; - goto fail; + return -1; } /* @@ -627,17 +624,17 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, if ((flags & MAP_TYPE) == MAP_SHARED && (target_prot & PROT_WRITE)) { errno = EINVAL; - goto fail; + return -1; } retaddr = target_mmap(start, len, target_prot | PROT_WRITE, (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (retaddr == -1) { - goto fail; + return -1; } if (pread(fd, g2h_untagged(start), len, offset) == -1) { - goto fail; + return -1; } if (!(target_prot & PROT_WRITE)) { ret = target_mprotect(start, len, target_prot); @@ -652,14 +649,14 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, /* one single host page */ if (!mmap_frag(real_start, start, last, target_prot, flags, fd, offset)) { - goto fail; + return -1; } goto the_end1; } if (!mmap_frag(real_start, start, real_start + host_page_size - 1, target_prot, flags, fd, offset)) { - goto fail; + return -1; } real_start += host_page_size; } @@ -669,7 +666,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, if (!mmap_frag(real_page, real_page, last, target_prot, flags, fd, offset + real_page - start)) { - goto fail; + return -1; } real_last -= host_page_size; } @@ -695,7 +692,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, munmap(p, len1); errno = EEXIST; } - goto fail; + return -1; } passthrough_start = real_start; passthrough_last = real_last; @@ -728,11 +725,22 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, qemu_log_unlock(f); } } - mmap_unlock(); return start; -fail: +} + +/* NOTE: all the constants are the HOST ones */ +abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, + int flags, int fd, off_t offset) +{ + abi_long ret; + + trace_target_mmap(start, len, target_prot, flags, fd, offset); + mmap_lock(); + + ret = target_mmap__locked(start, len, target_prot, flags, fd, offset); + mmap_unlock(); - return -1; + return ret; } static void mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) From patchwork Fri Aug 18 17:12:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714664 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp629651wrs; Fri, 18 Aug 2023 10:16:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHq/L7uBYoawSN1LGJr67ZZ5Rld92ksAxrWQpSMmbea/v4B/AnU1wzIz3AQQfwcKT6M7mL6 X-Received: by 2002:a0c:9c42:0:b0:649:c1ac:58a0 with SMTP id w2-20020a0c9c42000000b00649c1ac58a0mr2845033qve.64.1692378965433; Fri, 18 Aug 2023 10:16:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378965; cv=none; d=google.com; s=arc-20160816; b=mga6BSx37OrcaQz3Sa36xEmAJaDREGrHI1Q5nVUuGjlqjv5NBBof1ZO92av7azHgHL kZEnDChKp4UO9zkRvDy5BzOH5XcnMzkP1fEp1tEccMdHrAEZsWH4J7Nz2b2RAQoypxV6 Q46cWNgN6gDOyv6xBui9PrEH+CxjmJIHsllRKxslOB5OzWpppaMI1L04cnG9CnxAUNvF pGo65GVCwkRPTwRy+m+A9aaeh00gI7XmuG7jTFkG4a1hnZCCOFpPVFBfW/CT7GSIa4JY Exe2laskmv/ROVCFmAKBbVc9nuvmCSaG9kMxtujkIktKPK4loAwXBoPgsnU9WcVjqwL2 dAjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=jC5hJ3GCswcnU2akPG3677FrJC7qlQMO+Kr48jMs8x0=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=gogaf7+zkfN+Epe1mS3C7tt2qIWlmIzHStiOOZQrlCnmA1e3UHoVFwkpsHkgg4RPnG h2RmRXm/OGSMioCN9TXB/WmU9CEkKkj/9ZoigUK3sjIc1lwLbMnkjzHQuqQoVzNCTTfK 70Ey/agjOkzO3iFIhQ4lwTMtJrQWXkN8UgIVtSuBSjq/xrotkkHrZ3luefaUGhoeiEVI mB7qYA01y8H05CWMeseFmMdsiN7Dp8/ioivHPYM0crpHsRo5wf2V24nClJnADE8Avsfn OGIybsLcz41XyIvsfUnm+O/+VK8LoiQrEFGUVJsgj21hpu9rtUYQwTcT8Yi6OUbrhGoe 31Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E9P8z7+M; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w3-20020a0cdf83000000b00644c880072fsi1053533qvl.58.2023.08.18.10.16.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:16:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E9P8z7+M; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31x-0008ID-I7; Fri, 18 Aug 2023 13:13:01 -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 1qX31u-0008HL-GK for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:58 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31r-00083h-KP for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:57 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1bc0d39b52cso8890765ad.2 for ; Fri, 18 Aug 2023 10:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378774; x=1692983574; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=jC5hJ3GCswcnU2akPG3677FrJC7qlQMO+Kr48jMs8x0=; b=E9P8z7+MjnlM/t0kAdA+fic+Oz/P4/zT1GF13UGr2p/hwrPltpJcpADintxj1ocZKf /hRZ0h57VtUuL6Rp1OYk7Z0MwrSyKf5rVNbtFREmQEwOBo0991ZHsnMZ1kyiOnsc0BFT +Q9AOrS5B707iwqlHxEa5SSsYv0bt7Z4lUB+RqMTz8ye6Uj/O4QZFbFG52XEAa/6j0WN RGNBfFcQu06hx2cf/NPVeSmL9J5qUW9Jhe8ZcEOJcsGh03BsQOSjAPQ1pUwVypPi2sLD 2zSKpafby2qdA1gjic0KImR6GkeDG1HV9i/D+qwtkADg7d4z3IzIheKgett87OzzzU2E ZyXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378774; x=1692983574; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jC5hJ3GCswcnU2akPG3677FrJC7qlQMO+Kr48jMs8x0=; b=j5J1HpmQ/CCmd7lTSV0lGpbHe0JDq2rYfJu2kf6mLU7E8NxpZKuMijVtu3fYF/5rbC Vv12sliu42OrFixZsIcSvLEOt71ZYKr8ANX/sl2SbORbMZMEbPSfH+ysbfrOPRWrrozV vp0f8xtEgRcWcUhPJdwfbkbzXmTMDgnmVwCUelbI5xROOdwyLQdehXKvPzdD5kzJgHKe 0Cl/cc7guc7NRN3C42F2DA18fPa2MjTfszwwWcwPGaU1kIALSjcog5MShFmrUBk4gxDp Lz6gl0Z69iPTWMBcm5hA+Gf3TkObXYJ0BmOF1u30WKGRdzmLq1nr4M2Jze6yBs7C9y5Z WKIg== X-Gm-Message-State: AOJu0YyhQloNQtHgoVp1ceqUf4Qg35YXeoeHR0lnXq8LvlJw68z3RPTl c1HTqWEgHX+jgk7hzbSm9Yu9azuBvKMOXid5Oo0= X-Received: by 2002:a17:902:e88f:b0:1bb:b226:52a0 with SMTP id w15-20020a170902e88f00b001bbb22652a0mr3755997plg.44.1692378774005; Fri, 18 Aug 2023 10:12:54 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 17/33] linux-user: Move some mmap checks outside the lock Date: Fri, 18 Aug 2023 10:12:11 -0700 Message-Id: <20230818171227.141728-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Basic validation of operands does not require the lock. Hoist them from target_mmap__locked back into target_mmap. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/mmap.c | 107 +++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 448f168df1..85d16a29c1 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -447,52 +447,14 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) } static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, - int target_prot, int flags, + int target_prot, int flags, int page_flags, int fd, off_t offset) { int host_page_size = qemu_real_host_page_size(); abi_ulong ret, last, real_start, real_last, retaddr, host_len; abi_ulong passthrough_start = -1, passthrough_last = 0; - int page_flags; off_t host_offset; - if (!len) { - errno = EINVAL; - return -1; - } - - page_flags = validate_prot_to_pageflags(target_prot); - if (!page_flags) { - errno = EINVAL; - return -1; - } - - /* Also check for overflows... */ - len = TARGET_PAGE_ALIGN(len); - if (!len) { - errno = ENOMEM; - return -1; - } - - if (offset & ~TARGET_PAGE_MASK) { - errno = EINVAL; - return -1; - } - - /* - * If we're mapping shared memory, ensure we generate code for parallel - * execution and flush old translations. This will work up to the level - * supported by the host -- anything that requires EXCP_ATOMIC will not - * be atomic with respect to an external process. - */ - if (flags & MAP_SHARED) { - CPUState *cpu = thread_cpu; - if (!(cpu->tcg_cflags & CF_PARALLEL)) { - cpu->tcg_cflags |= CF_PARALLEL; - tb_flush(cpu); - } - } - real_start = start & -host_page_size; host_offset = offset & -host_page_size; @@ -572,23 +534,9 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, passthrough_start = start; passthrough_last = last; } else { - if (start & ~TARGET_PAGE_MASK) { - errno = EINVAL; - return -1; - } last = start + len - 1; real_last = ROUND_UP(last, host_page_size) - 1; - /* - * Test if requested memory area fits target address space - * It can fail only on 64-bit host with 32-bit target. - * On any other target/host host mmap() handles this error correctly. - */ - if (last < start || !guest_range_valid_untagged(start, len)) { - errno = ENOMEM; - return -1; - } - if (flags & MAP_FIXED_NOREPLACE) { /* Validate that the chosen range is empty. */ if (!page_check_range_empty(start, last)) { @@ -733,13 +681,64 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, int flags, int fd, off_t offset) { abi_long ret; + int page_flags; trace_target_mmap(start, len, target_prot, flags, fd, offset); + + if (!len) { + errno = EINVAL; + return -1; + } + + page_flags = validate_prot_to_pageflags(target_prot); + if (!page_flags) { + errno = EINVAL; + return -1; + } + + /* Also check for overflows... */ + len = TARGET_PAGE_ALIGN(len); + if (!len || len != (size_t)len) { + errno = ENOMEM; + return -1; + } + + if (offset & ~TARGET_PAGE_MASK) { + errno = EINVAL; + return -1; + } + if (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) { + if (start & ~TARGET_PAGE_MASK) { + errno = EINVAL; + return -1; + } + if (!guest_range_valid_untagged(start, len)) { + errno = ENOMEM; + return -1; + } + } + mmap_lock(); - ret = target_mmap__locked(start, len, target_prot, flags, fd, offset); + ret = target_mmap__locked(start, len, target_prot, flags, + page_flags, fd, offset); mmap_unlock(); + + /* + * If we're mapping shared memory, ensure we generate code for parallel + * execution and flush old translations. This will work up to the level + * supported by the host -- anything that requires EXCP_ATOMIC will not + * be atomic with respect to an external process. + */ + if (ret != -1 && (flags & MAP_TYPE) != MAP_PRIVATE) { + CPUState *cpu = thread_cpu; + if (!(cpu->tcg_cflags & CF_PARALLEL)) { + cpu->tcg_cflags |= CF_PARALLEL; + tb_flush(cpu); + } + } + return ret; } From patchwork Fri Aug 18 17:12:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714665 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp629678wrs; Fri, 18 Aug 2023 10:16:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGUrSAtM3Suil+E5gzEU0y5/P2YvHvMf9Z249iDWg4lHG0rxQkVxJZAtqu4KJ1PtCesFCnp X-Received: by 2002:a05:620a:c09:b0:76c:a564:c8c8 with SMTP id l9-20020a05620a0c0900b0076ca564c8c8mr3054443qki.66.1692378967918; Fri, 18 Aug 2023 10:16:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378967; cv=none; d=google.com; s=arc-20160816; b=MTdJ23+SrXx7UEBMBrCEWQrdGThK/qHmgYy5IeC0A6ZHdzh/UDbnz681ksJcfU4kWX J3rgQwxnpnxFcJSCSYtkcgblXG1JHifeJwrhUJ1G6IeMx3ov+KzW8A86r7bNA6cDX0Qm 2iUz+4NClyC5q1WIE+/gKt9oKggDgj2YCOtvHgg0Xpl9KmoOBu2ovPU0GoUHfByL1yq6 OogIyWJIQZq5tcaLeHrnBLIIrHZnbwg68ZDMzjzumMtOmkfOZwGAfeeKCqwdko/XO3K8 Cf9uWMHevL3au4SIsmy1cLzWHWeT4TwGujkNfuoneis6Ch+6RPMYoylddZJSXkBfHokU CAKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=5Yj/XvFLoTKPoAfaLaRz8qbNSbPbOFb4IFK3vAL5tQg=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=qPsZT+vUda/alb4zDE0LA6J1K1JAqfoQmm5Ieq/fHB7fb3Zr0gdZEVN8dJeb/what/ ANqfL5bND0Ml9qvan7vB7mtXTTcERwGWF9ergzMzeGdDH9Yrkm26YfDdkr3/1zVcpFrj D9TTHT2BD5awLdozD+FB+lXLR5qWAAm+ySay7cvw3XhObOCTyQcF9JW0miJyHe2/fPfm oUsJUjN1/M3fKbtxYKF8jVMpJxE3muRsd/NkJiskkFA+2U213VpUI7+vbog6gCiwB/LN 8Ow+qv6uRYjGO/1Oyi5dI03zbIekuRE3xncUNEfZCPSzKW7DpxNtme3t7eUOyIGPdCq8 NUHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A7HDiRyB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f11-20020a05620a280b00b007675745d82csi1397567qkp.758.2023.08.18.10.16.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:16:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A7HDiRyB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX31z-0008Ip-9s; Fri, 18 Aug 2023 13:13:03 -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 1qX31u-0008HM-Lb for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:58 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31s-00083l-3C for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:58 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bc8045e09dso8859205ad.0 for ; Fri, 18 Aug 2023 10:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378775; x=1692983575; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=5Yj/XvFLoTKPoAfaLaRz8qbNSbPbOFb4IFK3vAL5tQg=; b=A7HDiRyBaWFcD+TihQWGaqy1kQl1tBgYOW1jgiFHI029eqXaLnZ3a2KKi2OciBOkGK mX6Yv1nkoeIMt4y/mlVq17n8Akg4ev1svIjewJopkCk2PLBhC7l7N7qzzdtxLnXhGD4e ZSm5aYsKJQjpBIBuPcA+Q8MofwDd8JLQ0e9dLJ5t/2VHA6asVBqkfGrvg9fIeN7rIj9s f7rBXcSTC74ve5eUUhGfy5PNQ9eVKNLI3p1WqhblfCTUjf1kGG7EOj648B4mMfJGH0Vt kR7HUQZtPZYLe0WDDOWPTAFa3rEK+AGLtUUKYR5B+YhXVmr87oTuqPx/KZe6HX/PAuAn JPeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378775; x=1692983575; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5Yj/XvFLoTKPoAfaLaRz8qbNSbPbOFb4IFK3vAL5tQg=; b=lwaV+8L5UE1a445QvT+LLcTsjpJQAeKZzbr+RaQp700vwQzYY5b6fys/icqh5TsH97 uamuYD70ee6Mjt6/OJIgNRVGf57kJn9prr5ukmhYKH/THAHc2D8bvmv8H/AySghOHdKv BIHnb7PmRbbVXZjz+U5gIMs/ktpYMWKnJ+jZOgaG0GYVwmemgO9vgIxyujnzlM6URCML IpSZWsab44SvT3C3hYy361daep9wBBDlDszN8mnCgoIaXYle9PNcSHE3MJXls4H7sJVF hUH0cr+VmHcPi7R+hkfpYolF8BlZMS+Z7S8Au8os3/7ey8t2ZUX1PNA3vbDGS5fLQI1i Rk6Q== X-Gm-Message-State: AOJu0YxTLEivIWxMrAdfgpbE8vLFgt+8xT4oFakSP+rdFTYx0kv+ZLhw UQOQr90nNcul04r1cMRnpDiJhaWxhvTp4zbCSYE= X-Received: by 2002:a17:902:efcf:b0:1bd:c7e2:462 with SMTP id ja15-20020a170902efcf00b001bdc7e20462mr2928172plb.11.1692378774855; Fri, 18 Aug 2023 10:12:54 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 18/33] linux-user: Fix sub-host-page mmap Date: Fri, 18 Aug 2023 10:12:12 -0700 Message-Id: <20230818171227.141728-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We cannot skip over the_end1 to the_end, because we fail to record the validity of the guest page with the interval tree. Remove "the_end" and rename "the_end1" to "the_end". Signed-off-by: Richard Henderson --- linux-user/mmap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 85d16a29c1..e905b1b8f2 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -599,7 +599,7 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, target_prot, flags, fd, offset)) { return -1; } - goto the_end1; + goto the_end; } if (!mmap_frag(real_start, start, real_start + host_page_size - 1, @@ -646,7 +646,7 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, passthrough_last = real_last; } } - the_end1: + the_end: if (flags & MAP_ANONYMOUS) { page_flags |= PAGE_ANON; } @@ -663,7 +663,6 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, page_set_flags(passthrough_last + 1, last, page_flags); } } - the_end: trace_target_mmap_complete(start); if (qemu_loglevel_mask(CPU_LOG_PAGE)) { FILE *f = qemu_log_trylock(); From patchwork Fri Aug 18 17:12:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714671 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp630248wrs; Fri, 18 Aug 2023 10:17:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPrs9uoCA0TGQpya0n9hPAhjuoHMGS9TnpgbXJHyrwr6qhsCYdLOZRJBNY4C27L6kmme2s X-Received: by 2002:a0c:cdce:0:b0:64b:f3c:8a4a with SMTP id a14-20020a0ccdce000000b0064b0f3c8a4amr3350411qvn.22.1692379021838; Fri, 18 Aug 2023 10:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692379021; cv=none; d=google.com; s=arc-20160816; b=EKjmuObQppyHpOuA5uZVpyk6hz/CbcAEOO2pjnRCZTkU4VzcXulf73NUJJkR2Ah88C pDiyWo7fWIIKVvuX80yt4vbWCjvJkHxrTd9OB1Ag5AC2n1blGf39hCHNkXVHOZI3Ouuf x9IK6qR0FD5/2Cp5mpTqd4YSrtpmlcO3uZi+An2YUr4MBcofmNWnll1m9PhMQwehskIJ yHtXoKMkLP0U/LM5Y0cakPWaQyS+qFMhp4twlKa6H0QUkQWvqwNzLKjYzg8EH9oEErKm DRXVscd3nNgmfSCG8uWh4BAGcwF8d1p1I60XSLlyIgIQ876inWfdfNat12rAY0W9Hhtt yjyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=aZCDY6HGP026VqifIVtsa4bWLrsurTMJBgnQi1P0Q6s=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=zjz+keIa1LD9IwMLqVCzotWhnaqp8d/tKJaUaEmNQEGjAMGmaitpOOa+DGcJtmGdC+ 69Z45Lg+VBnd8uE9LD8LSlU0Qf88GEOoBV/RV/xIMbLl6RnRbsvqcELEWVe/JL0Py1sU MdQEDnIAlU6GWyuMQZbnAl+TxYvss3XsSxFgL5z1VlIPJzj3wF/hZDQityqGyBT0BEQE Yfk97lUxKiizykiJw9s/GZpKDun3uPOiyqzeGDtBAdc0NME8t9+ePjtx6oBiP410cPRO Z/VTnQ+BHjQI+AYUQua/uyZNMzj4R99BX3Nf2p1jVEObmz+ZWW6emD+NCMeLQRLb8B4r nefw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rzZTAbEZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j17-20020a0cf511000000b006418decf63asi1530157qvm.35.2023.08.18.10.17.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:17:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rzZTAbEZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX321-0008JT-G9; Fri, 18 Aug 2023 13:13:05 -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 1qX31w-0008IH-IA for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:01 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31u-00083s-5G for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:00 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1bb84194bf3so8862655ad.3 for ; Fri, 18 Aug 2023 10:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378775; x=1692983575; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=aZCDY6HGP026VqifIVtsa4bWLrsurTMJBgnQi1P0Q6s=; b=rzZTAbEZZzl96WAOoxxSWynUwNAe+tUbCrhbZRXFwztOaO4Wf2uvviaFU+anHiC/Rr DuLzvhjCJWJQ7BYDqUGfVqMv76rBEsH2azq6Sb0rbtS87OX2diQvaHlPo22lEL6TsdSs Dycghc7B7Kznv9SyppTsb+EoTEDxyxIRhshnc3F4qibD2VFtxVBursvUqf6udQhuzHaM FuAk77QyIGcZ9Z8GW10j9Mw+Rjt0517+z+UCXQ7DMynsYkJFYdZybG6PgNslCBxDVH5L mg7mRliccgQdU+juO2MlvhxQbx/OdQE+bdMzLFexHgLCV6zvkdJRfYdYpr+gc0ArIDwr 4foQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378775; x=1692983575; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aZCDY6HGP026VqifIVtsa4bWLrsurTMJBgnQi1P0Q6s=; b=HfYD2n/lhaIsuYGDGn3FEvajH+gQORZhuOxWT2jwVSsF97gi0gbTBW5g+Th1tAwEEY l4pku8N8HvYt9s9TPbd9yCEHIdQtE8QIUeU0vv+TQWhiIO92BKYXx+1OVtFlyMjQfoks d8+v1Jy+7CGG7jLoz2GJIMHL15L77pAouvQCGSzTzAkvtsJCTPtCfshOgqsak26xZIAo fyqStZGTvQDUK9budziNpfYCRGg6GCSb1cATX/lu91/2rJLGq6QTVkwoJ4LVukHAFqlv apwhvGvC5WVRfFX6EZ8tDDf8Z3qzqLFT5ADqlCRBmfgTf4sBHUh73HJX1WIfag6a/u0D Havw== X-Gm-Message-State: AOJu0Ywo1wdhSOXF2ysyxH2XDw1Y+FIGT86z3wKWyXWp9XAmEejdBdyK eGbfJHnrfUwmvBkGqjfEwW5PSWANZ3Bv5dU5ydk= X-Received: by 2002:a17:902:bd93:b0:1b8:3786:3344 with SMTP id q19-20020a170902bd9300b001b837863344mr2458204pls.49.1692378775563; Fri, 18 Aug 2023 10:12:55 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 19/33] linux-user: Split out mmap_end Date: Fri, 18 Aug 2023 10:12:13 -0700 Message-Id: <20230818171227.141728-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use a subroutine instead of a goto within target_mmap__locked. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/mmap.c | 69 +++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index e905b1b8f2..caa76eb11a 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -446,6 +446,42 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) } } +/* + * Record a successful mmap within the user-exec interval tree. + */ +static abi_long mmap_end(abi_ulong start, abi_ulong last, + abi_ulong passthrough_start, + abi_ulong passthrough_last, + int flags, int page_flags) +{ + if (flags & MAP_ANONYMOUS) { + page_flags |= PAGE_ANON; + } + page_flags |= PAGE_RESET; + if (passthrough_start > passthrough_last) { + page_set_flags(start, last, page_flags); + } else { + if (start < passthrough_start) { + page_set_flags(start, passthrough_start - 1, page_flags); + } + page_set_flags(passthrough_start, passthrough_last, + page_flags | PAGE_PASSTHROUGH); + if (passthrough_last < last) { + page_set_flags(passthrough_last + 1, last, page_flags); + } + } + trace_target_mmap_complete(start); + if (qemu_loglevel_mask(CPU_LOG_PAGE)) { + FILE *f = qemu_log_trylock(); + if (f) { + fprintf(f, "page layout changed following mmap\n"); + page_dump(f); + qemu_log_unlock(f); + } + } + return start; +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_flags, int fd, off_t offset) @@ -588,7 +624,7 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, ret = target_mprotect(start, len, target_prot); assert(ret == 0); } - goto the_end; + return mmap_end(start, last, -1, 0, flags, page_flags); } /* handle the start of the mapping */ @@ -599,7 +635,7 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, target_prot, flags, fd, offset)) { return -1; } - goto the_end; + return mmap_end(start, last, -1, 0, flags, page_flags); } if (!mmap_frag(real_start, start, real_start + host_page_size - 1, @@ -646,33 +682,8 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, passthrough_last = real_last; } } - the_end: - if (flags & MAP_ANONYMOUS) { - page_flags |= PAGE_ANON; - } - page_flags |= PAGE_RESET; - if (passthrough_start > passthrough_last) { - page_set_flags(start, last, page_flags); - } else { - if (start < passthrough_start) { - page_set_flags(start, passthrough_start - 1, page_flags); - } - page_set_flags(passthrough_start, passthrough_last, - page_flags | PAGE_PASSTHROUGH); - if (passthrough_last < last) { - page_set_flags(passthrough_last + 1, last, page_flags); - } - } - trace_target_mmap_complete(start); - if (qemu_loglevel_mask(CPU_LOG_PAGE)) { - FILE *f = qemu_log_trylock(); - if (f) { - fprintf(f, "page layout changed following mmap\n"); - page_dump(f); - qemu_log_unlock(f); - } - } - return start; + return mmap_end(start, last, passthrough_start, passthrough_last, + flags, page_flags); } /* NOTE: all the constants are the HOST ones */ From patchwork Fri Aug 18 17:12:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714673 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp630331wrs; Fri, 18 Aug 2023 10:17:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYC4sQ692dL45xZHqHNCLf2Nl7wEjohJ7gl+WqW4Rzzl2RaXDMhckNDOtfrwPl3tFuBA9U X-Received: by 2002:a05:620a:22d3:b0:76c:b69c:957f with SMTP id o19-20020a05620a22d300b0076cb69c957fmr3184393qki.39.1692379030848; Fri, 18 Aug 2023 10:17:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692379030; cv=none; d=google.com; s=arc-20160816; b=Lr2ctKjFNIZBZ/KVOtwwEGWRPxhHzD2NZ5oKIFzKBDEoB68O8Sx/ue9VHhTWRMOpk5 2PcrNdoMi7hWljpZlKyP/6s9IrogorHG2BlN7a9RhUdN5u0QBSzfO/uOdMtMqOvOUYfX pi25NeC6DgAOMV6ScnNX9/Mm0YUS5irOo0ky7G8/PsuhRuCALikOs5XhaJReyx9jUZHX Zo0WsogQ2k2LAkhDvhTTo9NVVcqsSftDT/aezp5S3GAGOJ0O19JzojKX4LXUGp0QOwg9 LhcgjNBP9kLWGdB28LrtPj5NaEJnBb3SSPgrs+Qey5jqF0ANI8MD2Av5N3/DxWWKPEU1 gsyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=7kaLhwLbHzHqv/PeQXejQChX9nX84J3A2xjA5ly6h/g=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=q5FZjDTbBZHD0v6Rii54WIV6a9V8yI4zNGvZVhPMxOlMe2k9hwRB/zM79rKv/h/U9F golW4mgoyO5uRxWeT51FdCFDAEhk5tufVPZ20T+7WwPfZWTGtuE/Zh6cNVglCf9OypDL Xc0gBtmEh38hzIw2VEYIMXXY9NLN2Xrn7TkWg9PI40gMCKrCuKFuzWRHPzLRkTXz11XY SruTekZB3ex3i0BLXhAlsp4HCPwcgdXMGaY0LZaczkHxs++yWgE2go6UBENK4KCMt1C2 ja9Vxx2+R7KUv17ZBPp3ZTeF0PRVzW8kxr/RaZSlAiONbOb1Cc/qKyviwOGj0gLtU5Mv MyqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f05l70vv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n10-20020a05620a294a00b0076cc577010fsi1531839qkp.307.2023.08.18.10.17.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:17:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f05l70vv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX321-0008LV-Sr; Fri, 18 Aug 2023 13:13:05 -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 1qX31w-0008Hw-Cc for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:00 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31u-000842-67 for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:00 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1bf48546ccfso4262025ad.2 for ; Fri, 18 Aug 2023 10:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378776; x=1692983576; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=7kaLhwLbHzHqv/PeQXejQChX9nX84J3A2xjA5ly6h/g=; b=f05l70vvYRnhP6y8m0P6u93FGTrUdJXkBcUtMGA8dicHwjrgjt2KocZ7vBUDREeKEs 7YH/bin0vbLa5Y+1RJsBUnLSEm3Y6+JmZ+lnqsnXpWCgQ80i3QfEh3PLI1lYLpMPi8s2 dhkkQzEGl4pJ+/xkDIIx1EVu+akQBBmOkuIQiyJ1RzhzkKHIjIBkAbEpe7/Y3/ZL3Qjm NmUoqACjgD4G88F+LdmPOEo9lu/qXbMHBvmacdlmVauYhWUzrdPBApUW8uPL1eVmEB3c CQOuxjcl1jNuQSpCcLkMRkWtLw5xS+33rHMQzODC/hcRZ7cCPGm7iaxoFA/qcVhH3K4O RoRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378776; x=1692983576; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7kaLhwLbHzHqv/PeQXejQChX9nX84J3A2xjA5ly6h/g=; b=QOcpHFn2ep6H/bmwBuK6Qsoe3rO26FdQD39bV/nJTpd2MQRUw3KMyByVfnwvBdqtk+ Pw27OBzHD5v9J/5k/vHV2IqyCO1+J1wyv3CURUHzrezG6KhrQXuImIeX9/QqSEPY5E95 4pRIyLuHxQfBhP1UmeYePjJuDdabntA0Liyvd3O1AkUSS26yxn+++YCaB3xOmJ7jH51I Gqwi9N7Ku90iS+sysnSWksHaW6Om8IevSBm9OevA6xKn/FB0w0dioOrPFsRwFcpQFwQo AQMk0U11+63Dxc6kR2NitCF5AwySHMypjj/P6v62kZmw9q6NP6Xx53eV4zeJVGZbXKbs L9Tg== X-Gm-Message-State: AOJu0Yx3S4JXA8wkZ2RyRbES8bLmwbdbDLAG+1ucdWY9vEZ6Jw/WGf6I PzII3TrB+xnIBslOtZikx6U0869jWafixlYaekE= X-Received: by 2002:a17:903:449:b0:1be:f76e:7664 with SMTP id iw9-20020a170903044900b001bef76e7664mr2650251plb.29.1692378776321; Fri, 18 Aug 2023 10:12:56 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 20/33] linux-user: Do early mmap placement only for reserved_va Date: Fri, 18 Aug 2023 10:12:14 -0700 Message-Id: <20230818171227.141728-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org For reserved_va, place all non-fixed maps then proceed as for MAP_FIXED. Signed-off-by: Richard Henderson --- linux-user/mmap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index caa76eb11a..7d482df06d 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -495,17 +495,19 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, host_offset = offset & -host_page_size; /* - * If the user is asking for the kernel to find a location, do that - * before we truncate the length for mapping files below. + * For reserved_va, we are in full control of the allocation. + * Find a suitible hole and convert to MAP_FIXED. */ - if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { + if (reserved_va && !(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { host_len = len + offset - host_offset; - host_len = ROUND_UP(host_len, host_page_size); - start = mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); + start = mmap_find_vma(real_start, host_len, + MAX(host_page_size, TARGET_PAGE_SIZE)); if (start == (abi_ulong)-1) { errno = ENOMEM; return -1; } + start += offset - host_offset; + flags |= MAP_FIXED; } /* From patchwork Fri Aug 18 17:12:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714669 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp630212wrs; Fri, 18 Aug 2023 10:16:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqdz8f9gMlrh/KGZJKxzEVFp2V/A9Cuv1dRbpEBoeOtbu/Xed2+reV4+loCeu0iJ639WbU X-Received: by 2002:a05:6830:10c2:b0:6b9:4d79:e08a with SMTP id z2-20020a05683010c200b006b94d79e08amr3326657oto.32.1692379019542; Fri, 18 Aug 2023 10:16:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692379019; cv=none; d=google.com; s=arc-20160816; b=bLHoLAA/tT3l0iw8SnLiUvtabkBh3w27RWFubSgIDopfv9QQAI+g9xzqk69/JDpa4M nraLbkIWLpeSh17h/IY0PK0kGSr0EvvVIy7O5rGDftc9RxxTXf0x8A2cuMUactSGwr14 9QzRzJFIROVrQQVZgeLt/F+csJyEy6iOppItfq55n3ZbEk2giKry6VLuCBIVoBMD3DnI Y1yD9p7XrVDg7MzbzGvaYNenEvuvdbmwKjyCWzzfk81t0O2CA+eJ3WYTN7zgB9TCpZWD NGWSHnkjttJLg64+jRMrh2BNQBWYMnrROHI7SKu87EkzPQvv+HMZGE/mecZ+u0Fhprv7 lY6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ySu5X2pwP/FjpufFI3frCgcVNyTN0K5y3i0eNXjPfK8=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=wKYF7JDQdGSyht8swhSWrlIYiLZNYOLOxUi2k0YD9Oit4UH/dP7z53KAlclrD/DI/L kPPQDqELVPf0doTy5HD4v8Jze9/HsF/cZ96kG2CTd0UFde5Ul00nN48ogLvsdqEUchVx YdMWuk7Z8cPaF4SwSMILiHS3Br6MHMPa3hlPpmztaH5AUNZWgzutxDB6wKSPRboTzuIS 2DorbAPCbF9jLZb5WtMsiJg+SG38I/Rqi6rLzE2abRA8mmywOAQO5iv+8NVdNX79MxND JxWsJxdT0t+gXfTCgQuvXnAtFKCkXFNQ75TMcBVjtLDyN+I51rWBEvYaWhbONw/Fboyo 634g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ecJDup/X"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j7-20020ac85f87000000b003ff46b1caf0si1496195qta.551.2023.08.18.10.16.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:16:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ecJDup/X"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX322-0008M4-Fs; Fri, 18 Aug 2023 13:13:06 -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 1qX31y-0008IW-5U for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:02 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31u-000848-DK for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:01 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1bc73a2b0easo9421905ad.0 for ; Fri, 18 Aug 2023 10:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378777; x=1692983577; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ySu5X2pwP/FjpufFI3frCgcVNyTN0K5y3i0eNXjPfK8=; b=ecJDup/XEPfibIvZ2A8m964UBWDcwzIeCtPZHvZ8OJv+eXTm0riS3yR+jiqZVBjHds 4xtPO/MGWMjLtxSEUUOWjv/VqgTLZzlE57c3qGrnA5a+ql5n2qlUWpts2PA39ysi3Fr0 +5DI5OWiBl4gdcFqt32djc/eYy/CYYQBwcmyP9Xj27ssh4rGTyrVAr+eQsfm1VpWFRJ4 Q0BtVy5alvUwM3E26llm4vpYJfMlMLiiEtN8N9Y3OEQhYHXp38vX6YYKkvtJKO8ZaMcZ AuQqAR2uLbmFfuAypzIStza0Y8TDIcIRB9GnQQT22Bs0odMZgPjPdERCK9+1/7i+hXrj NyHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378777; x=1692983577; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ySu5X2pwP/FjpufFI3frCgcVNyTN0K5y3i0eNXjPfK8=; b=RH77LztNnSz20HvFyWUTnx3c8dUqKvfBwWrGviF5GZO0UpI7KKh1oMKc8XKU88PxGi kbYfUyXqhwDDQ7Bn21y5L2uY7anbTIUUWPUajw1W2oKMlH1i9sQ882cQEB5YKD3hSndO iT6frXgfjrIX/6xv+ul/M43/13Nrl3xIoga6FTkcQIsaxH3WwYDr7JdstF1B5up2b+8N LZR+PQfCmv8/HkLCgQqRoDgxHEKphxApLOrD8rJ81GW5CCqb/oXGh8LMsXfl+ecb349s 6GVclmGwtSZtekWfdjr0EP5WrTPun9Xs5kw+OIGEwZg1G/Qc87iVwgCpIGcX81TbY/vD XZBQ== X-Gm-Message-State: AOJu0YzAv75R6058KBV0jf/YNoreb+Tqw6n1obzACvrLnvSbTVwSlpfm I+Fr/cffE52HupnnztJuih4/ydof6cQZf6/ImC4= X-Received: by 2002:a17:902:748a:b0:1bd:e64c:5c70 with SMTP id h10-20020a170902748a00b001bde64c5c70mr3348825pll.7.1692378777054; Fri, 18 Aug 2023 10:12:57 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 21/33] linux-user: Split out mmap_h_eq_g Date: Fri, 18 Aug 2023 10:12:15 -0700 Message-Id: <20230818171227.141728-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Move the MAX_FIXED_NOREPLACE check for reserved_va earlier. Move the computation of host_prot earlier. Signed-off-by: Richard Henderson --- linux-user/mmap.c | 66 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 7d482df06d..7a0c0c1f35 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -482,6 +482,31 @@ static abi_long mmap_end(abi_ulong start, abi_ulong last, return start; } +/* + * Special case host page size == target page size, + * where there are no edge conditions. + */ +static abi_long mmap_h_eq_g(abi_ulong start, abi_ulong len, + int host_prot, int flags, int page_flags, + int fd, off_t offset) +{ + void *p, *want_p = g2h_untagged(start); + abi_ulong last; + + p = mmap(want_p, len, host_prot, flags, fd, offset); + if (p == MAP_FAILED) { + return -1; + } + if ((flags & MAP_FIXED_NOREPLACE) && p != want_p) { + errno = EEXIST; + return -1; + } + + start = h2g(p); + last = start + len - 1; + return mmap_end(start, last, start, last, flags, page_flags); +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_flags, int fd, off_t offset) @@ -490,6 +515,7 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, abi_ulong ret, last, real_start, real_last, retaddr, host_len; abi_ulong passthrough_start = -1, passthrough_last = 0; off_t host_offset; + int host_prot; real_start = start & -host_page_size; host_offset = offset & -host_page_size; @@ -498,16 +524,33 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, * For reserved_va, we are in full control of the allocation. * Find a suitible hole and convert to MAP_FIXED. */ - if (reserved_va && !(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { - host_len = len + offset - host_offset; - start = mmap_find_vma(real_start, host_len, - MAX(host_page_size, TARGET_PAGE_SIZE)); - if (start == (abi_ulong)-1) { - errno = ENOMEM; - return -1; + if (reserved_va) { + if (flags & MAP_FIXED_NOREPLACE) { + /* Validate that the chosen range is empty. */ + if (!page_check_range_empty(start, start + len - 1)) { + errno = EEXIST; + return -1; + } + flags = (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED; + } else if (!(flags & MAP_FIXED)) { + size_t real_len = len + offset - host_offset; + abi_ulong align = MAX(host_page_size, TARGET_PAGE_SIZE); + + start = mmap_find_vma(real_start, real_len, align); + if (start == (abi_ulong)-1) { + errno = ENOMEM; + return -1; + } + start += offset - host_offset; + flags |= MAP_FIXED; } - start += offset - host_offset; - flags |= MAP_FIXED; + } + + host_prot = target_to_host_prot(target_prot); + + if (host_page_size == TARGET_PAGE_SIZE) { + return mmap_h_eq_g(start, len, host_prot, flags, + page_flags, fd, offset); } /* @@ -543,12 +586,10 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { uintptr_t host_start; - int host_prot; void *p; host_len = len + offset - host_offset; host_len = ROUND_UP(host_len, host_page_size); - host_prot = target_to_host_prot(target_prot); /* Note: we prefer to control the mapping address. */ p = mmap(g2h_untagged(start), host_len, host_prot, @@ -671,8 +712,7 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, len1 = real_last - real_start + 1; want_p = g2h_untagged(real_start); - p = mmap(want_p, len1, target_to_host_prot(target_prot), - flags, fd, offset1); + p = mmap(want_p, len1, host_prot, flags, fd, offset1); if (p != want_p) { if (p != MAP_FAILED) { munmap(p, len1); From patchwork Fri Aug 18 17:12:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714674 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp630336wrs; Fri, 18 Aug 2023 10:17:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHGiI3eT9OghSSXVcnUG4CBiJFQT9NBHUEcFXlqJHdoLIEmCGujgah4xF+7dRL0NllLBLPB X-Received: by 2002:a05:622a:151:b0:403:b103:248 with SMTP id v17-20020a05622a015100b00403b1030248mr4593648qtw.4.1692379031160; Fri, 18 Aug 2023 10:17:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692379031; cv=none; d=google.com; s=arc-20160816; b=ONiFi22wHdAZeRkNOQpCVONDSY/JY7hhyl3A0tvVdaEnEUDgoQbOFKEIJzNEAqmi43 eES9/gFZH1BLbac/qxPyo5yIq/8DUcmGTBKLiKSVLaKM9f5vKI8E8NrH0cAHhoHuwJZy 5f+gZ/oxCi7FEpBZAPDd0qRrkv+bTSSSkw94RvO58m2z1I88QHJ3bMMEhwHO0xCnTGIN pf8aCSnf1PebnNpgM8kxUPggyQORHT+kHomf0aoJ+kWfocn8NnLVEw+jlrPBdUjdT2n5 O+t/p2JAuzfqBBsDtUhY2tR6FP6ELlB5XxBfvVe1zdE1sFi8wWRwbwlPGP32G5v5Sxvy ijYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=4bucLpoT0vquWNBuZLTOreK2BOdVySJCazC6PuHo6Rk=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=OLp+FFL7at7TgO4fUxHzyefxD5WVPGt646AUGscEJTF/beCMR0sqjyJeFR+UkinQiR hEOrJsAFYF9G2WLblk4pcTgo8mb//QaSG+cyBdvtm0y1fHtEWlKdmsbG5XHTOIJV7VbQ 2eobgmdBgZzF3i0/epJJz2y94Uu3V9JJUg4WO2jgfB3HVqgxBjj+SXqlrkzkfSNt/CgR 9FdHn30Lf1vaf9e/wv6NeYRw7fBEMeGqWVauccKZGiMIlwqOa/hI56joAlhF225IXNl2 LzkzjCyrEhpydkl/sbk4byp19kYoDmwE/v6HdXc2tRuZ1E7qf6mCVtRWgk4F5BDN6lwl pRVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZCaWLtRO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k19-20020ac85fd3000000b004034944f9d8si1522266qta.111.2023.08.18.10.17.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:17:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZCaWLtRO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX324-0008OF-67; Fri, 18 Aug 2023 13:13:08 -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 1qX31y-0008Ia-Ff for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:02 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31v-00085c-Vl for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:02 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1bc5acc627dso8833235ad.1 for ; Fri, 18 Aug 2023 10:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378778; x=1692983578; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=4bucLpoT0vquWNBuZLTOreK2BOdVySJCazC6PuHo6Rk=; b=ZCaWLtRO9P1T02CRbutzXY9rxnMJeCP+gcQYTIlQbzksZxPQ5uAlTAM8qNJYJxCrJ8 NjdBD+9uoXPzKys9Y988CJBKSzAGXXBD/4hjSca1dvGuaN2Jk1ufUL33GHIildsTboZa zzr3xqwDHpS99S7D7TqWXakLZpogXy7xyHtA5Xa/mis8QgpOoCpmN6JQcAD4ZYUCQ5p0 +UpZj5uBrSxxTAZRnOK7P97jcDKlbhNaKy3n9ZcjpHzxfXZKSCucZy5b4JXxt+O19JGg 0YG/ZoYNl3nFJZJKzETU18FVMu1/ibX0NILDX6GHuC0S4oIsVupBJXrSEtYmSTy2Gq3W mU7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378778; x=1692983578; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4bucLpoT0vquWNBuZLTOreK2BOdVySJCazC6PuHo6Rk=; b=FX1L4QAc58E/Qjf9i6diteHaHzxtwT/OUMGfWjA+2FTMr4ilviDwe4Ssw3uYD5I7wC hdFsIu0L2mXUTgIF4B9D4/HXTdJ40AYjWuR0fwS/tFfcAo8mVpwZ9Xo/ZJ1uXtt6rSmM vtvh9b4aRorpfZjoCay7BOfaWbrZh4ZeMGGZsqZDVSXvSe5m4wrn8nQJLw/SZSzjUizV /NuFQ0tr6fDIGnYfULlBi6cAOa5o7B07T+DBL50D+erMn3e5DLQpAPJsu/EIcA9flxlI dvwC/uleX9FDsL1Z6qCChHowhQ8pcCVl4Bjv0HXT9HNiItsvah36Tj+WVKU1s0HZkFVN GLBQ== X-Gm-Message-State: AOJu0YyQB5cWpUxakAM6wKh0XLquMMMVtyA/TLc1+m1zC0RrJD99jdNn aYLz5ZiKpt41XUHFbH/rmaqJpCxs5/YoLDJ2VMk= X-Received: by 2002:a17:902:c3d1:b0:1bd:ba57:5a8f with SMTP id j17-20020a170902c3d100b001bdba575a8fmr3161386plj.13.1692378777771; Fri, 18 Aug 2023 10:12:57 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 22/33] linux-user: Split out mmap_h_lt_g Date: Fri, 18 Aug 2023 10:12:16 -0700 Message-Id: <20230818171227.141728-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Work much harder to get alignment and mapping beyond the end of the file correct. Both of which are excercised by our test-mmap for alpha (8k pages) on any 4k page host. Signed-off-by: Richard Henderson --- linux-user/mmap.c | 156 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 125 insertions(+), 31 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 7a0c0c1f35..ed82b4bb75 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -507,6 +507,128 @@ static abi_long mmap_h_eq_g(abi_ulong start, abi_ulong len, return mmap_end(start, last, start, last, flags, page_flags); } +/* + * Special case host page size < target page size. + * + * The two special cases are increased guest alignment, and mapping + * past the end of a file. + * + * When mapping files into a memory area larger than the file, + * accesses to pages beyond the file size will cause a SIGBUS. + * + * For example, if mmaping a file of 100 bytes on a host with 4K + * pages emulating a target with 8K pages, the target expects to + * be able to access the first 8K. But the host will trap us on + * any access beyond 4K. + * + * When emulating a target with a larger page-size than the hosts, + * we may need to truncate file maps at EOF and add extra anonymous + * pages up to the targets page boundary. + * + * This workaround only works for files that do not change. + * If the file is later extended (e.g. ftruncate), the SIGBUS + * vanishes and the proper behaviour is that changes within the + * anon page should be reflected in the file. + * + * However, this case is rather common with executable images, + * so the workaround is important for even trivial tests, whereas + * the mmap of of a file being extended is less common. + */ +static abi_long mmap_h_lt_g(abi_ulong start, abi_ulong len, int host_prot, + int mmap_flags, int page_flags, int fd, + off_t offset, int host_page_size) +{ + void *p, *want_p = g2h_untagged(start); + off_t fileend_adj = 0; + int flags = mmap_flags; + abi_ulong last, pass_last; + + if (!(flags & MAP_ANONYMOUS)) { + struct stat sb; + + if (fstat(fd, &sb) == -1) { + return -1; + } + if (offset >= sb.st_size) { + /* + * The entire map is beyond the end of the file. + * Transform it to an anonymous mapping. + */ + flags |= MAP_ANONYMOUS; + fd = -1; + offset = 0; + } else if (offset + len > sb.st_size) { + /* + * A portion of the map is beyond the end of the file. + * Truncate the file portion of the allocation. + */ + fileend_adj = offset + len - sb.st_size; + } + } + + if (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) { + if (fileend_adj) { + p = mmap(want_p, len, host_prot, flags | MAP_ANONYMOUS, -1, 0); + } else { + p = mmap(want_p, len, host_prot, flags, fd, offset); + } + if (p != want_p) { + if (p != MAP_FAILED) { + munmap(p, len); + errno = EEXIST; + } + return -1; + } + + if (fileend_adj) { + void *t = mmap(p, len - fileend_adj, host_prot, + (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED, + fd, offset); + assert(t != MAP_FAILED); + } + } else { + size_t host_len, part_len; + + /* + * Take care to align the host memory. Perform a larger anonymous + * allocation and extract the aligned portion. Remap the file on + * top of that. + */ + host_len = len + TARGET_PAGE_SIZE - host_page_size; + p = mmap(want_p, host_len, host_prot, flags | MAP_ANONYMOUS, -1, 0); + if (p == MAP_FAILED) { + return -1; + } + + part_len = (uintptr_t)p & (TARGET_PAGE_SIZE - 1); + if (part_len) { + part_len = TARGET_PAGE_SIZE - part_len; + munmap(p, part_len); + p += part_len; + host_len -= part_len; + } + if (len < host_len) { + munmap(p + len, host_len - len); + } + + if (!(flags & MAP_ANONYMOUS)) { + void *t = mmap(p, len - fileend_adj, host_prot, + flags | MAP_FIXED, fd, offset); + assert(t != MAP_FAILED); + } + + start = h2g(p); + } + + last = start + len - 1; + if (fileend_adj) { + pass_last = ROUND_UP(last - fileend_adj, host_page_size) - 1; + } else { + pass_last = last; + } + return mmap_end(start, last, start, pass_last, mmap_flags, page_flags); +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_flags, int fd, off_t offset) @@ -551,37 +673,9 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, if (host_page_size == TARGET_PAGE_SIZE) { return mmap_h_eq_g(start, len, host_prot, flags, page_flags, fd, offset); - } - - /* - * When mapping files into a memory area larger than the file, accesses - * to pages beyond the file size will cause a SIGBUS. - * - * For example, if mmaping a file of 100 bytes on a host with 4K pages - * emulating a target with 8K pages, the target expects to be able to - * access the first 8K. But the host will trap us on any access beyond - * 4K. - * - * When emulating a target with a larger page-size than the hosts, we - * may need to truncate file maps at EOF and add extra anonymous pages - * up to the targets page boundary. - */ - if (host_page_size < TARGET_PAGE_SIZE && !(flags & MAP_ANONYMOUS)) { - struct stat sb; - - if (fstat(fd, &sb) == -1) { - return -1; - } - - /* Are we trying to create a map beyond EOF?. */ - if (offset + len > sb.st_size) { - /* - * If so, truncate the file map at eof aligned with - * the hosts real pagesize. Additional anonymous maps - * will be created beyond EOF. - */ - len = ROUND_UP(sb.st_size - offset, host_page_size); - } + } else if (host_page_size < TARGET_PAGE_SIZE) { + return mmap_h_lt_g(start, len, host_prot, flags, + page_flags, fd, offset, host_page_size); } if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { From patchwork Fri Aug 18 17:12:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714643 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp628229wrs; Fri, 18 Aug 2023 10:13:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuP3l1ssoHCwb78oMR3/i3jEaw0xr/dfVEfkrytwTbF9xY0dNoLkxvREalw1giKVXcZVKy X-Received: by 2002:ac8:5b07:0:b0:40e:2e60:e3d4 with SMTP id m7-20020ac85b07000000b0040e2e60e3d4mr8678792qtw.31.1692378834235; Fri, 18 Aug 2023 10:13:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378834; cv=none; d=google.com; s=arc-20160816; b=V1F3/riRZk828JNDdm+d/zL+BYOvXE+h49sQWoQCkAlkN+gmIdmIxpo81ksNvtf+Dh BhDRdndFWrB0rdaoaWpr0eA8pSFeMRYLFhNHZ6tHbjQWrngqj2GklTh8o+fCTc9ExguY 2b5PeziSCpTUXpMy8ThQnGerlHts8Bw6v+vr8L91MDURUduQg2om/0q7sd8JAaPmBz7L cQSgTfmQZle+kx0SpvImx1H5HQJQ3AhEY/tgknnP29w9stI+Thd1gN8734gra0q86Foi OQuix0NXVafFGAGykutfxeTo97ictQturrMzlz49HTgsV9pjlfw50BO92dAE8Ns02CTq MjZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=NJQTkGtLKBIQbaCTGpYdZiGcCYcEb9NdqL6VTgxKtpE=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=c6FNr7rZIhG+02SwYzkpytnMcfN+kyxKV3aMwd6QeVYVVkmHH+Fpx6PXBjORtSYmNd 649pLF5a8JxrpCARFsj0x5A0qMa5Mk1MUzyZ6gDEcv/hlqYdfsiI7YG2Z0Vg10qMdHvI QlkEDHIBFtS81mEyTYLRgE9EsBA3HwZeIAS6DLIBOOcLWqPb6DSOcwGq3Es2PrtxX/uc 2KRzUOfnFYtjAmRpfNbrFR6JIygWli+k2MFjr+AMsmKqx3V4m/fqQxtLISFJRNXBo6pC CUjgvgF/2A8wkvPbM63WCCosEEN1iXX2tzQuxndqd6nmbDpN94YaWmwBUXLcz1vEFuSh tQRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MKOXdcZ2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i3-20020ac85c03000000b004069531fb6fsi1468906qti.530.2023.08.18.10.13.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:13:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MKOXdcZ2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX323-0008OB-SV; Fri, 18 Aug 2023 13:13:07 -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 1qX31y-0008J6-SI for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:03 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31v-00086A-W3 for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:02 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1bf1935f6c2so8162175ad.1 for ; Fri, 18 Aug 2023 10:12:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378778; x=1692983578; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=NJQTkGtLKBIQbaCTGpYdZiGcCYcEb9NdqL6VTgxKtpE=; b=MKOXdcZ2mIMQAgXyF7v9Mn6NJyn3hTe4tOWq4+M7zT029YoQKCzjttrcwndUX/1R/t r5SePbSeI/dH1QmI256zKm4raglh7KBWYanEB4MxDupHd3H31xNSb8QiG7hb0JxOQ/jG BCVzD9K+veYN5g4D4DgIA5nXM49/6BzLgxKnE3RCbqc2jZiIFrLw/RF8tY3Om2klslTm CzosTV/cxUJaXzfeXWggDEX7Sbfc/Ey3KVEKBumys/63xwZ+5nQz7QuxVaCLt16cS1fm K/Ruci7INSiQbX9mQX/orlt1X9IiaSE72nXrbVYPxmCutiCSgYeVZEW6H18dBGK6hQpn 1rlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378778; x=1692983578; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NJQTkGtLKBIQbaCTGpYdZiGcCYcEb9NdqL6VTgxKtpE=; b=ALdGJCSmiUE7cr/ERZxEc2mJLVNl4zASruzkObXLJlbw1mY/ULc1fa7HMwzleWZ8+7 XGkJggAtD3TvAIpUNFYauydpS7FuLhKnEDj39w2tubFG5Gv/yt5gaJj0cm9SS1nqviDd NlO9ySjTtsO08HnAaor0l5rm04uhgvqW3MMtGAh/uIgMYdJhT9CUIrhhWQBhTPJ6vK1q JIrF9FKJwIZtslftQ0L4z4GpyCWVAPxbe7nOeypUepYNdbwILwcVdM7T9dlKzeCPVb1M MSLFFqBnxD9QcJ2pXGz8FRNRz//f36vW0TSNlt008U1zB+ahrX/rktWTjDkIyv8cmAnG fciw== X-Gm-Message-State: AOJu0YwfSZ08gYsU3XZ7MsWSPh8Y50z6rMcqD1aKgBHFnNjl0Wtlu25C CddEMzjQTTR9KQutljt+3/oXlLCn1RTw2aXVikc= X-Received: by 2002:a17:902:c946:b0:1bb:85cd:9190 with SMTP id i6-20020a170902c94600b001bb85cd9190mr4541863pla.18.1692378778464; Fri, 18 Aug 2023 10:12:58 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 23/33] linux-user: Split out mmap_h_gt_g Date: Fri, 18 Aug 2023 10:12:17 -0700 Message-Id: <20230818171227.141728-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson --- linux-user/mmap.c | 288 ++++++++++++++++++++++------------------------ 1 file changed, 139 insertions(+), 149 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index ed82b4bb75..6ab2f35e6f 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -223,7 +223,16 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) return ret; } -/* map an incomplete host page */ +/* + * Map an incomplete host page. + * + * Here be dragons. This case will not work if there is an existing + * overlapping host page, which is file mapped, and for which the mapping + * is beyond the end of the file. In that case, we will see SIGBUS when + * trying to write a portion of this page. + * + * FIXME: Work around this with a temporary signal handler and longjmp. + */ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last, int prot, int flags, int fd, off_t offset) { @@ -629,19 +638,138 @@ static abi_long mmap_h_lt_g(abi_ulong start, abi_ulong len, int host_prot, return mmap_end(start, last, start, pass_last, mmap_flags, page_flags); } +/* + * Special case host page size > target page size. + * + * The two special cases are address and file offsets that are valid + * for the guest that cannot be directly represented by the host. + */ +static abi_long mmap_h_gt_g(abi_ulong start, abi_ulong len, + int target_prot, int host_prot, + int flags, int page_flags, int fd, + off_t offset, int host_page_size) +{ + void *p, *want_p = g2h_untagged(start); + off_t host_offset = offset & -host_page_size; + abi_ulong last, real_start, real_last; + bool misaligned_offset = false; + size_t host_len; + + if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { + /* + * Adjust the offset to something representable on the host. + */ + host_len = len + offset - host_offset; + p = mmap(want_p, host_len, host_prot, flags, fd, host_offset); + if (p == MAP_FAILED) { + return -1; + } + + /* Update start to the file position at offset. */ + p += offset - host_offset; + + start = h2g(p); + last = start + len - 1; + return mmap_end(start, last, start, last, flags, page_flags); + } + + if (!(flags & MAP_ANONYMOUS)) { + misaligned_offset = (start ^ offset) & (host_page_size - 1); + + /* + * The fallback for misalignment is a private mapping + read. + * This carries none of semantics required of MAP_SHARED. + */ + if (misaligned_offset && (flags & MAP_TYPE) != MAP_PRIVATE) { + errno = EINVAL; + return -1; + } + } + + last = start + len - 1; + real_start = start & -host_page_size; + real_last = ROUND_UP(last, host_page_size) - 1; + + /* + * Handle the start and end of the mapping. + */ + if (real_start < start) { + abi_ulong real_page_last = real_start + host_page_size - 1; + if (last <= real_page_last) { + /* Entire allocation a subset of one host page. */ + if (!mmap_frag(real_start, start, last, target_prot, + flags, fd, offset)) { + return -1; + } + return mmap_end(start, last, -1, 0, flags, page_flags); + } + + if (!mmap_frag(real_start, start, real_page_last, target_prot, + flags, fd, offset)) { + return -1; + } + real_start = real_page_last + 1; + } + + if (last < real_last) { + abi_ulong real_page_start = real_last - host_page_size + 1; + if (!mmap_frag(real_page_start, real_page_start, last, + target_prot, flags, fd, + offset + real_page_start - start)) { + return -1; + } + real_last = real_page_start - 1; + } + + if (real_start > real_last) { + return mmap_end(start, last, -1, 0, flags, page_flags); + } + + /* + * Handle the middle of the mapping. + */ + + host_len = real_last - real_start + 1; + want_p += real_start - start; + + if (flags & MAP_ANONYMOUS) { + p = mmap(want_p, host_len, host_prot, flags, -1, 0); + } else if (!misaligned_offset) { + p = mmap(want_p, host_len, host_prot, flags, fd, + offset + real_start - start); + } else { + p = mmap(want_p, host_len, host_prot | PROT_WRITE, + flags | MAP_ANONYMOUS, -1, 0); + } + if (p != want_p) { + if (p != MAP_FAILED) { + munmap(p, host_len); + errno = EEXIST; + } + return -1; + } + + if (misaligned_offset) { + /* TODO: The read could be short. */ + if (pread(fd, p, host_len, offset + real_start - start) != host_len) { + munmap(p, host_len); + return -1; + } + if (!(host_prot & PROT_WRITE)) { + mprotect(p, host_len, host_prot); + } + } + + return mmap_end(start, last, -1, 0, flags, page_flags); +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_flags, int fd, off_t offset) { int host_page_size = qemu_real_host_page_size(); - abi_ulong ret, last, real_start, real_last, retaddr, host_len; - abi_ulong passthrough_start = -1, passthrough_last = 0; - off_t host_offset; int host_prot; - real_start = start & -host_page_size; - host_offset = offset & -host_page_size; - /* * For reserved_va, we are in full control of the allocation. * Find a suitible hole and convert to MAP_FIXED. @@ -655,6 +783,8 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, } flags = (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED; } else if (!(flags & MAP_FIXED)) { + abi_ulong real_start = start & -host_page_size; + off_t host_offset = offset & -host_page_size; size_t real_len = len + offset - host_offset; abi_ulong align = MAX(host_page_size, TARGET_PAGE_SIZE); @@ -676,150 +806,10 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, } else if (host_page_size < TARGET_PAGE_SIZE) { return mmap_h_lt_g(start, len, host_prot, flags, page_flags, fd, offset, host_page_size); - } - - if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { - uintptr_t host_start; - void *p; - - host_len = len + offset - host_offset; - host_len = ROUND_UP(host_len, host_page_size); - - /* Note: we prefer to control the mapping address. */ - p = mmap(g2h_untagged(start), host_len, host_prot, - flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); - if (p == MAP_FAILED) { - return -1; - } - /* update start so that it points to the file position at 'offset' */ - host_start = (uintptr_t)p; - if (!(flags & MAP_ANONYMOUS)) { - p = mmap(g2h_untagged(start), len, host_prot, - flags | MAP_FIXED, fd, host_offset); - if (p == MAP_FAILED) { - munmap(g2h_untagged(start), host_len); - return -1; - } - host_start += offset - host_offset; - } - start = h2g(host_start); - last = start + len - 1; - passthrough_start = start; - passthrough_last = last; } else { - last = start + len - 1; - real_last = ROUND_UP(last, host_page_size) - 1; - - if (flags & MAP_FIXED_NOREPLACE) { - /* Validate that the chosen range is empty. */ - if (!page_check_range_empty(start, last)) { - errno = EEXIST; - return -1; - } - - /* - * With reserved_va, the entire address space is mmaped in the - * host to ensure it isn't accidentally used for something else. - * We have just checked that the guest address is not mapped - * within the guest, but need to replace the host reservation. - * - * Without reserved_va, despite the guest address check above, - * keep MAP_FIXED_NOREPLACE so that the guest does not overwrite - * any host address mappings. - */ - if (reserved_va) { - flags = (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED; - } - } - - /* - * worst case: we cannot map the file because the offset is not - * aligned, so we read it - */ - if (!(flags & MAP_ANONYMOUS) && - (offset & (host_page_size - 1)) != (start & (host_page_size - 1))) { - /* - * msync() won't work here, so we return an error if write is - * possible while it is a shared mapping - */ - if ((flags & MAP_TYPE) == MAP_SHARED - && (target_prot & PROT_WRITE)) { - errno = EINVAL; - return -1; - } - retaddr = target_mmap(start, len, target_prot | PROT_WRITE, - (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) - | MAP_PRIVATE | MAP_ANONYMOUS, - -1, 0); - if (retaddr == -1) { - return -1; - } - if (pread(fd, g2h_untagged(start), len, offset) == -1) { - return -1; - } - if (!(target_prot & PROT_WRITE)) { - ret = target_mprotect(start, len, target_prot); - assert(ret == 0); - } - return mmap_end(start, last, -1, 0, flags, page_flags); - } - - /* handle the start of the mapping */ - if (start > real_start) { - if (real_last == real_start + host_page_size - 1) { - /* one single host page */ - if (!mmap_frag(real_start, start, last, - target_prot, flags, fd, offset)) { - return -1; - } - return mmap_end(start, last, -1, 0, flags, page_flags); - } - if (!mmap_frag(real_start, start, - real_start + host_page_size - 1, - target_prot, flags, fd, offset)) { - return -1; - } - real_start += host_page_size; - } - /* handle the end of the mapping */ - if (last < real_last) { - abi_ulong real_page = real_last - host_page_size + 1; - if (!mmap_frag(real_page, real_page, last, - target_prot, flags, fd, - offset + real_page - start)) { - return -1; - } - real_last -= host_page_size; - } - - /* map the middle (easier) */ - if (real_start < real_last) { - void *p, *want_p; - off_t offset1; - size_t len1; - - if (flags & MAP_ANONYMOUS) { - offset1 = 0; - } else { - offset1 = offset + real_start - start; - } - len1 = real_last - real_start + 1; - want_p = g2h_untagged(real_start); - - p = mmap(want_p, len1, host_prot, flags, fd, offset1); - if (p != want_p) { - if (p != MAP_FAILED) { - munmap(p, len1); - errno = EEXIST; - } - return -1; - } - passthrough_start = real_start; - passthrough_last = real_last; - } + return mmap_h_gt_g(start, len, target_prot, host_prot, flags, + page_flags, fd, offset, host_page_size); } - return mmap_end(start, last, passthrough_start, passthrough_last, - flags, page_flags); } /* NOTE: all the constants are the HOST ones */ From patchwork Fri Aug 18 17:12:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714666 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp629719wrs; Fri, 18 Aug 2023 10:16:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMTU9I4lm3yBLjpBtKpCLEsAZysXeTPAh8ZaDxGqYawWzU11/A8cHnCw4gSKL9SFuQA0ik X-Received: by 2002:ad4:4ea4:0:b0:63c:913f:2b18 with SMTP id ed4-20020ad44ea4000000b0063c913f2b18mr9283386qvb.2.1692378972057; Fri, 18 Aug 2023 10:16:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378972; cv=none; d=google.com; s=arc-20160816; b=YQZeOCP5Z1vJpDJcdpku96S0IaqcBhfsVHL2AwadwK1C7MxWYmVfxLZGaMyFHILC48 1AVkBzs+nheU1bNet1/p3YgtzrsGUBjqIdo5Px1b6wK+S1wwSMXLAWnNJ4YW0na6Y+e/ RL4pAA8BON0UL7CQlOZJc9IxIWsov874VEFuYtIa8LsIGcH9PHQIac7GgBCN4BG3IQ/E gSbZcJxnkqZ93TrBERbENMXeq0aZJjnpaaT9+WzVPtXQF9F1CSGT5djfcpfA0itTVjzH pUfoB48zZsvpvfSlTdx2WpywKwfxUFRCzyOU/fMdmw3Qq+Mqk+MipYCf1X9rSar+yaL7 k3dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=JVa+6i7ltaDcVRVgM1SyKlnzNS7CnHg1qkG8lXGAgc8=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=WUI0FiQtE825mc+fRZeQWJqdw10ZDrl4c1qCnA5CU7UWYn89lVzhHcj4JoxZ9FA1Do F4wKK8/6IxBZI61VUGDQPWXKoDrl4mokAJE2AiTmPAR3xrjQak/tmAuebEwwkQWH07jd IHvP0ZYKHmCDhKNO+atHUS1i/l3moEH2LghpyUU70iZ5yPP+G5D0dWy7Za+BkT9W3kXu qpuU3N/lKIjbfuVZ18oYFx2fsHn+Aibukcd47MBk92ZsR2TUBMehar/4czwIp9cgX6ug WfyYrB3S9EWyFpElr9YjblhhIOF+r9QDQCNu3qOKmWnR/JN+mvA6nZfciDi2iDEzH8j0 vV/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TtEnDoTO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bi37-20020a05620a31a500b007680efdb225si1449108qkb.152.2023.08.18.10.16.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:16:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TtEnDoTO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX324-0008OP-Ei; Fri, 18 Aug 2023 13:13:08 -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 1qX320-0008Ja-6L for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:05 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31x-00086J-EX for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:03 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1bf1935f6c2so8162275ad.1 for ; Fri, 18 Aug 2023 10:13:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378779; x=1692983579; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=JVa+6i7ltaDcVRVgM1SyKlnzNS7CnHg1qkG8lXGAgc8=; b=TtEnDoTO2HnjYSybEtdONXV+9T5Piz/yiitCNn3/rgwGMyLkWoV/hUviR6ClMX0CU1 Y5C7ebmX3akZroWq8VyieDI6Voorf6oYb+VhDfFKXxEiU+RiWnyBMXvGAJF0E3vKPCF9 o33KFefD+FO2uWsLa/0eHVApz+d+zxF5CdKB+eaTR2adu8M9bHl82073NRuVhz5Er+Ln sSTaPgWmsx3NJa9h+pMkW2LpWlWBTNmfSiZEKk6a6abzh2EdUmyJCAwHSgfGubpJpqY7 jVRanQqegiecGeTBoKHEMmS/yvZiHiNs6pVZae2Hzi5fajdPuKE/w8eSwEpIXYxLThCV yg+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378779; x=1692983579; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JVa+6i7ltaDcVRVgM1SyKlnzNS7CnHg1qkG8lXGAgc8=; b=dADEY3nMpZebI6/RN3CtkWPLrEdz/+xRp8+iCGXawkeDtH/KGHCBAttfoTDyj06xGf o0g303WLsYLjSHUaW1/QkJQ+1mS5YbPowlPu7Cg2rlGkbQMvcLhdnn4RG9cCqf5VqSDA r66aDyzSAYCDcjzhvY4M7xGb1IP/c+twmH1bKcWWpTFowp6DAfegMwBm0Z0XIixQT96I x7OWAvpG9PdaHuQJoz1YCVVDJ9d9rjWmHeGYBToWnXcqIRB7GTQADIWfDZyn5n5ULhTb hK30PvXNgs3tR8aQB1m81309Qh18zx9XMlbFLjReC0BcNnPjiPrRYxwm7y0U2d4s2My9 8mqA== X-Gm-Message-State: AOJu0YzSPV3eeqYUdIrjwVeLyZPpF4W+qUDfoRVQuJK8PB7fj4VIPwcO VhP5ElvU/A/gKeK4S1HkqKd6xoC1LiEGcW5j0kY= X-Received: by 2002:a17:903:230f:b0:1bc:7312:78e2 with SMTP id d15-20020a170903230f00b001bc731278e2mr9114708plh.5.1692378779174; Fri, 18 Aug 2023 10:12:59 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 24/33] tests/tcg: Remove run-test-mmap-* Date: Fri, 18 Aug 2023 10:12:18 -0700 Message-Id: <20230818171227.141728-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These tests are confused, because -p does not change the guest page size, but the host page size. Signed-off-by: Richard Henderson --- tests/tcg/alpha/Makefile.target | 3 --- tests/tcg/arm/Makefile.target | 3 --- tests/tcg/hppa/Makefile.target | 3 --- tests/tcg/i386/Makefile.target | 3 --- tests/tcg/m68k/Makefile.target | 3 --- tests/tcg/multiarch/Makefile.target | 9 --------- tests/tcg/ppc/Makefile.target | 12 ------------ tests/tcg/sh4/Makefile.target | 3 --- tests/tcg/sparc64/Makefile.target | 6 ------ 9 files changed, 45 deletions(-) delete mode 100644 tests/tcg/ppc/Makefile.target delete mode 100644 tests/tcg/sparc64/Makefile.target diff --git a/tests/tcg/alpha/Makefile.target b/tests/tcg/alpha/Makefile.target index b94500a7d9..fdd7ddf64e 100644 --- a/tests/tcg/alpha/Makefile.target +++ b/tests/tcg/alpha/Makefile.target @@ -13,6 +13,3 @@ test-cmov: test-cond.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) run-test-cmov: test-cmov - -# On Alpha Linux only supports 8k pages -EXTRA_RUNS+=run-test-mmap-8192 diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target index 0038cef02c..4b8c9c334e 100644 --- a/tests/tcg/arm/Makefile.target +++ b/tests/tcg/arm/Makefile.target @@ -79,6 +79,3 @@ sha512-vector: sha512.c ARM_TESTS += sha512-vector TESTS += $(ARM_TESTS) - -# On ARM Linux only supports 4k pages -EXTRA_RUNS+=run-test-mmap-4096 diff --git a/tests/tcg/hppa/Makefile.target b/tests/tcg/hppa/Makefile.target index cdd0d572a7..ea5ae2186d 100644 --- a/tests/tcg/hppa/Makefile.target +++ b/tests/tcg/hppa/Makefile.target @@ -2,9 +2,6 @@ # # HPPA specific tweaks - specifically masking out broken tests -# On parisc Linux supports 4K/16K/64K (but currently only 4k works) -EXTRA_RUNS+=run-test-mmap-4096 # run-test-mmap-16384 run-test-mmap-65536 - # This triggers failures for hppa-linux about 1% of the time # HPPA is the odd target that can't use the sigtramp page; # it requires the full vdso with dwarf2 unwind info. diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target index fdf757c6ce..f64d7bfbf5 100644 --- a/tests/tcg/i386/Makefile.target +++ b/tests/tcg/i386/Makefile.target @@ -71,9 +71,6 @@ endif I386_TESTS:=$(filter-out $(SKIP_I386_TESTS), $(ALL_X86_TESTS)) TESTS=$(MULTIARCH_TESTS) $(I386_TESTS) -# On i386 and x86_64 Linux only supports 4k pages (large pages are a different hack) -EXTRA_RUNS+=run-test-mmap-4096 - sha512-sse: CFLAGS=-msse4.1 -O3 sha512-sse: sha512.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) diff --git a/tests/tcg/m68k/Makefile.target b/tests/tcg/m68k/Makefile.target index 1163c7ef03..73a16aedd2 100644 --- a/tests/tcg/m68k/Makefile.target +++ b/tests/tcg/m68k/Makefile.target @@ -5,6 +5,3 @@ VPATH += $(SRC_PATH)/tests/tcg/m68k TESTS += trap - -# On m68k Linux supports 4k and 8k pages (but 8k is currently broken) -EXTRA_RUNS+=run-test-mmap-4096 # run-test-mmap-8192 diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target index 43bddeaf21..fa1ac190f2 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -51,18 +51,9 @@ run-plugin-vma-pthread-with-%: vma-pthread $(call skip-test, $<, "flaky on CI?") endif -# We define the runner for test-mmap after the individual -# architectures have defined their supported pages sizes. If no -# additional page sizes are defined we only run the default test. - -# default case (host page size) run-test-mmap: test-mmap $(call run-test, test-mmap, $(QEMU) $<, $< (default)) -# additional page sizes (defined by each architecture adding to EXTRA_RUNS) -run-test-mmap-%: test-mmap - $(call run-test, test-mmap-$*, $(QEMU) -p $* $<, $< ($* byte pages)) - ifneq ($(HAVE_GDB_BIN),) ifeq ($(HOST_GDB_SUPPORTS_ARCH),y) GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py diff --git a/tests/tcg/ppc/Makefile.target b/tests/tcg/ppc/Makefile.target deleted file mode 100644 index f5e08c7376..0000000000 --- a/tests/tcg/ppc/Makefile.target +++ /dev/null @@ -1,12 +0,0 @@ -# -*- Mode: makefile -*- -# -# PPC - included from tests/tcg/Makefile -# - -ifneq (,$(findstring 64,$(TARGET_NAME))) -# On PPC64 Linux can be configured with 4k (default) or 64k pages (currently broken) -EXTRA_RUNS+=run-test-mmap-4096 #run-test-mmap-65536 -else -# On PPC32 Linux supports 4K/16K/64K/256K (but currently only 4k works) -EXTRA_RUNS+=run-test-mmap-4096 #run-test-mmap-16384 run-test-mmap-65536 run-test-mmap-262144 -endif diff --git a/tests/tcg/sh4/Makefile.target b/tests/tcg/sh4/Makefile.target index 47c39a44b6..16eaa850a8 100644 --- a/tests/tcg/sh4/Makefile.target +++ b/tests/tcg/sh4/Makefile.target @@ -3,9 +3,6 @@ # SuperH specific tweaks # -# On sh Linux supports 4k, 8k, 16k and 64k pages (but only 4k currently works) -EXTRA_RUNS+=run-test-mmap-4096 # run-test-mmap-8192 run-test-mmap-16384 run-test-mmap-65536 - # This triggers failures for sh4-linux about 10% of the time. # Random SIGSEGV at unpredictable guest address, cause unknown. run-signals: signals diff --git a/tests/tcg/sparc64/Makefile.target b/tests/tcg/sparc64/Makefile.target deleted file mode 100644 index 408dace783..0000000000 --- a/tests/tcg/sparc64/Makefile.target +++ /dev/null @@ -1,6 +0,0 @@ -# -*- Mode: makefile -*- -# -# sparc specific tweaks - -# On Sparc64 Linux support 8k pages -EXTRA_RUNS+=run-test-mmap-8192 From patchwork Fri Aug 18 17:12:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714661 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp629560wrs; Fri, 18 Aug 2023 10:15:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRrOWos0K1cZ0ViEuDWTVFw/MJRG+rgbWMxxwfP8d9wa1oR0tscw9/uHthO4YLPtLHFrfv X-Received: by 2002:ac8:5a88:0:b0:407:fd3b:c6ed with SMTP id c8-20020ac85a88000000b00407fd3bc6edmr3667403qtc.41.1692378955398; Fri, 18 Aug 2023 10:15:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378955; cv=none; d=google.com; s=arc-20160816; b=MjQTVCt7XU2YZsxBcDMRK4wSf0bfcdKWwjXNcth4vripYB98sBnU+ImqYW5XvdrSsR kZjGTvaE9hLIasDu499XiHSQFwO8S6nEt1cQ0ADdGW8OnojAabxylN5THr3NSHM6+tmv xmquE88Eejpgf2INu4UTWcni5nALufH61KjtzdFrncjL/B2/HVmAmGzSDWe+srN+qCNI KXTHnp7yZmkN0Z0A1zbYz7a7EdoNO7F7+049mKdZdc9/8zCKEJqgaN/sLhLLLkuSzw1M pD7pYT3xjUdPA66zhXXjqCwSLT+C1aTY0mAuxgoNkT2SnrBPKlPia74KcS6Ipi4lzqN4 66nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=rdwt79BwZaWBN00DwtMN42IvreCD09Jb8OcGXDyYgYc=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=USE0NxAwcL3QHt9VjlKOKBnKJAF3caUN35Gg3+Nb0d0Y1thwVdpUFGJ4ZNZAP3F+FD QEt3V+8plk2uuXRL2dbNgAIgFFR67A+OeZoBpB2Xl+S/6fz9DQzl+ucL9KLJhBSU0wqm O4lk4PYZdgLhpI/IHDh+rQWGbbBcA8Mo338p8QFPCVS2Ys6hKdPu4Kk8ZtBgWj9y/EOr XxTHuiHtMklrQa4DatOEviQn5blnQdOX2cCwMFDfBjeohvKmd2qBtth68Q9qgqmHCvel fBkwWTWrNewjeVpKrwQUnNVEvecrgZjS6d0+4y8wZBWRVZ1NpsMCo8QFDjCY5kj9hSma glWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bw0Pj8oE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j6-20020a05622a038600b00403bb8819a3si1391821qtx.800.2023.08.18.10.15.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:15:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bw0Pj8oE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX324-0008OT-Pr; Fri, 18 Aug 2023 13:13:08 -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 1qX31z-0008JY-W0 for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:05 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31x-00086d-OI for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:03 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1bf3a2f44f0so6379325ad.2 for ; Fri, 18 Aug 2023 10:13:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378780; x=1692983580; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=rdwt79BwZaWBN00DwtMN42IvreCD09Jb8OcGXDyYgYc=; b=bw0Pj8oEUVgthlGpaMA+PZHB+Of/T13bg0doLYlK9tFSelKS93ZAG1duFsXvhpcehl fEc9oMraE8E8G+fTTsKsRdT4pL5dqVFoQI8+Uf97xTzbCdHiwUqMRVrbnFcHdckGBnbu 5TFXKdAenjxrA/v0eGBYC2JzC1m4uamqAWu+EFYmfpnbKzuwM+jhrIlTlaLKBBGGdHxx wBKBpyNTDJ8tuglfoUSlY8Ob3m7UhYCOKGmvhHiV+lKFWlaDcT0l2pCV53xlH/7Sv93N qme/Z2m7unimtvc2jaWR3O91n8eZqv1Ca8FTji/H5/YM3XXFOZ1rezaxguZO8Y/D1oh9 h2yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378780; x=1692983580; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rdwt79BwZaWBN00DwtMN42IvreCD09Jb8OcGXDyYgYc=; b=mCny+Ny3ilRmlyy70kAUDl1i1XwrzEqraE9AXLa60U3XEfgOEF9FDJbCipnBOpE2lF QxuEAoCmIOoVSNIazQ5s5BxmwTBwmRdC+swkh3bPujyHV7depqjkly7v72sD6fqp1UQg jPiZHpl8kbb42A3UHJ+R+4iwxT+dDTvKRuUGB28Xv/a+e1epm7/6LGeMipOJjlR7YZZV jdJ7hvXPOu2gkHo+kJAUpR5ha5PaqbtIrrIuWuxj2SZzlUwxjoYTEsmiQkKZY77TU5DU /lpEd0mH4KuFf1WUgJtQqtFBdp3rd33pcLdjvZ8FhDKrlmvl+YYLdmdshiiX1W0y9+M2 85NA== X-Gm-Message-State: AOJu0YzGnhXNFxlXrnr7I7ggbFYrhlgV+0U9+S82x4yzBcl8a9aMWfWJ C6sVvEx0hkU5XT7mvBRXMZMIGCWnlY2UV2jS8EM= X-Received: by 2002:a17:902:db03:b0:1b2:4852:9a5f with SMTP id m3-20020a170902db0300b001b248529a5fmr3548246plx.54.1692378779880; Fri, 18 Aug 2023 10:12:59 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 25/33] tests/tcg: Extend file in linux-madvise.c Date: Fri, 18 Aug 2023 10:12:19 -0700 Message-Id: <20230818171227.141728-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org When guest page size > host page size, this test can fail due to the SIGBUS protection hack. Avoid this by making sure that the file size is at least one guest page. Visible with alpha guest on x86_64 host. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tests/tcg/multiarch/linux/linux-madvise.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/tcg/multiarch/linux/linux-madvise.c b/tests/tcg/multiarch/linux/linux-madvise.c index 29d0997e68..539fb3b772 100644 --- a/tests/tcg/multiarch/linux/linux-madvise.c +++ b/tests/tcg/multiarch/linux/linux-madvise.c @@ -42,6 +42,8 @@ static void test_file(void) assert(ret == 0); written = write(fd, &c, sizeof(c)); assert(written == sizeof(c)); + ret = ftruncate(fd, pagesize); + assert(ret == 0); page = mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE, fd, 0); assert(page != MAP_FAILED); From patchwork Fri Aug 18 17:12:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714654 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp628770wrs; Fri, 18 Aug 2023 10:14:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKoow9duNIvYBauTL8gSO7qXo7Jm7WEF91nL39M9+psOKXZv9Z3ZoJVcay4anKqpOGV9Fb X-Received: by 2002:ae9:f408:0:b0:76c:b43e:8f12 with SMTP id y8-20020ae9f408000000b0076cb43e8f12mr3628963qkl.39.1692378886884; Fri, 18 Aug 2023 10:14:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378886; cv=none; d=google.com; s=arc-20160816; b=P/5RG9Bq5FVP+qt6Af5N3Y7eMLVsV61DYK9n3sN4aBSC8xzy43yulPZNwUFSzXgJx/ xGKgViLK0JJtidTyc1FPZhP98x0XTqnEvodrlm2daBh0wLk0bb87KieXW7TitFrLJXZw R1LRcrPjyx9AcGgLJULVPPV24hcZQrqEI3oumf4W7THtkYD4Qa8KcgkqHxGp4PrnEgno wvVvkLrP7BA9KDiyiVRg68ke4y19p4+anbuAFk7G9X9VG16UzFz3VdWuQ+A6yTdSuWWI AnhB+9vd5DRzpDLkxF7WpDUEzw+ZySpTpJYJWS622bAA18mCohSUs2yfPlGFF04bSiK9 TAeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=FBWXK2o1QI213n+CXudGJA2Q6k8dmEbYGhoqpLagvf0=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=vkbi4BzaodGFbukjP5LR9v+s8D/kY00K5InoN3I7uJUgm81ypedm3cT8mZRvv5GCo9 j+aQzJ1T1wnakc/F0fzVxrbKKg15+iciYq0jltdcCKg0btN5IUbVXdeqM4oNZ2eIqi3Y Gf7zKXCuOTPIYfTNwJfu/uSE3fH2R5lyKAmk60gbOGdsu66JgSHX9nKI7tKhcBKPVJrm eKPEAIAlOVFCuRdjU1KlPJWLK0U1mShJe6DUIu1v/P/5+lxkGkBxUu6uPCqrPnriPEjh hgn1ZkIRttZsH8A0EJ0Dgvml2hdM18SzPk9hySNJvBqWgRTQfiQIzPbQr+n10JTuINyx vMYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FnuKhpln; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bk33-20020a05620a1a2100b0076cdb47c487si1428141qkb.283.2023.08.18.10.14.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:14:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FnuKhpln; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX323-0008Mt-35; Fri, 18 Aug 2023 13:13:07 -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 1qX320-0008Jc-CV for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:05 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31x-00086q-PM for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:04 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1bf3a2f44f0so6379445ad.2 for ; Fri, 18 Aug 2023 10:13:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378780; x=1692983580; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=FBWXK2o1QI213n+CXudGJA2Q6k8dmEbYGhoqpLagvf0=; b=FnuKhpln339jwIBI+ES0FtOPqRQf5OTTZW9Mx0n9J1PKCu6xdKZhwaF+i30snDjJRN 7L+EniJBNBA4ZobUjd2BVOQagbXWvItj502wXnFMss7qlKRjI7oxiCHe0WBfhXk9yd3C NEQFywNrsbl+5jwl2UPbZmroJv9VQaP2JaOuW+pZiakbx/lDOm9VWFZZN0WhtzQocJ10 0RYkDLcWCON3R56wl7zt93FmXLm/FNEB7l85a1wNQ4f+meQ9eicF9ceE8Nciv2PbOVRK fyiIHOV3fcGT13CIHHe1L9NpVgBH4UB2uS7rzh32MIFKTtOGxk1YG343FrlplVTUhNxR oL3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378780; x=1692983580; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FBWXK2o1QI213n+CXudGJA2Q6k8dmEbYGhoqpLagvf0=; b=DhofAZH2DmRiEyPFTs5yoWtB1/gPvlnsI/UlxaweP4uSWbO7AsClWjn23UpYpA4aXB 1vdDGsC/3lqzHMCBBQLr21YOEPW3UHZCTilRldGs+oqK/MKV0c7K+cq3zQbJffPlCAHT Q60oYkA6wQBvc/mIK82ZsUMqSBAsQNiUR9UOOz41J7mZA5KaAEe5vWMrEYsdfkQ71/IZ 1fuItK0rsRoKgpe2/41GYkN4hLcV8DdNG2n3rSmIVow7uYpj+ytSDVn44WAWNtVRkZQt oVgUFfCbgTLrjtQBXLRp6l+oiuQAGzP3m3ziJmfszMszB0nBNutoaZ0SO+mPeEujC9L3 4enQ== X-Gm-Message-State: AOJu0Yz4aQ8PLwhJptMKpux+VljZy1xaW1dbkJc7YwdU1vRA4KqBnaVL 4Sd6I+bpH6niCcKSpWFSVjH93xZnkr2SgjIkoHo= X-Received: by 2002:a17:902:ecc9:b0:1bc:7001:6e62 with SMTP id a9-20020a170902ecc900b001bc70016e62mr3637749plh.35.1692378780545; Fri, 18 Aug 2023 10:13:00 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:13:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 26/33] linux-user: Deprecate and disable -p pagesize Date: Fri, 18 Aug 2023 10:12:20 -0700 Message-Id: <20230818171227.141728-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This option controls the host page size. From the mis-usage in our own testsuite, this is easily confused with guest page size. The only thing that occurs when changing the host page size is that stuff breaks, because one cannot actually change the host page size. Therefore reject all but the no-op setting as part of the deprecation process. Signed-off-by: Richard Henderson --- linux-user/main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index c1058abc3c..3dd3310331 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -332,10 +332,11 @@ static void handle_arg_ld_prefix(const char *arg) static void handle_arg_pagesize(const char *arg) { - qemu_host_page_size = atoi(arg); - if (qemu_host_page_size == 0 || - (qemu_host_page_size & (qemu_host_page_size - 1)) != 0) { - fprintf(stderr, "page size must be a power of two\n"); + unsigned size, want = qemu_real_host_page_size(); + + if (qemu_strtoui(arg, NULL, 10, &size) || size != want) { + error_report("Deprecated page size option cannot " + "change host page size (%u)", want); exit(EXIT_FAILURE); } } @@ -496,7 +497,7 @@ static const struct qemu_argument arg_table[] = { {"D", "QEMU_LOG_FILENAME", true, handle_arg_log_filename, "logfile", "write logs to 'logfile' (default stderr)"}, {"p", "QEMU_PAGESIZE", true, handle_arg_pagesize, - "pagesize", "set the host page size to 'pagesize'"}, + "pagesize", "deprecated change to host page size"}, {"one-insn-per-tb", "QEMU_ONE_INSN_PER_TB", false, handle_arg_one_insn_per_tb, "", "run with one guest instruction per emulated TB"}, From patchwork Fri Aug 18 17:12:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714645 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp628341wrs; Fri, 18 Aug 2023 10:14:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF6Q0JLz8vrN4Va1opnplqkp9WGOLuVpud/PiNAdqnboOAb+9GCitEUd+AiMhrlS0kHj0Hk X-Received: by 2002:a05:6214:5804:b0:647:2039:3525 with SMTP id mk4-20020a056214580400b0064720393525mr3370891qvb.35.1692378845723; Fri, 18 Aug 2023 10:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378845; cv=none; d=google.com; s=arc-20160816; b=ay10B13Y4LXfz6fnDP8Hl864JP0Va5bu4RgA4dzYNKjOTfU0GW0BUeL7UO7jvuo1P/ y4z6zMidEwkmf0DnrGCJCww6woGg5H7EhNPbsNR3GSUG1VfS5yaALi/9rC0Jdziw6FCI Xf3SIJcsnDDulQ4XcQwK5FHCusB+NTuK+fvBmA536Oy70lPtmvnBL+ESWOWTkRBrpuqi owhglaMppWZmsdWyt3QxESh789PyOD0uFfa62nOu/dezikG8k9s466WHwPSls1ufccKp qiUNbip4D6sHZzXK2TEEfGGCWNzhUmOOCjRhFH273h6F3zCD0yhMj8PtgcgJpaxvHXBt S17A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ataiAyODkAIfirPwE5L7zXmqt5E+aKGaPeIxcvvLwCA=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=IjHLkLHoiXFHYLWHfpAvsrNWXPJjs6q51dmiCbThpVIGl4Pb12YsxN2DUuOfJt7bLh SrigrgdV8NsLsDcDlgYsb0vOF0PAvfvpz1QlpAK1MuNW5ebjjrqQVOZy8ENbV7NBxmts 5/ypYP5MMz7rWjmuqZygxgNgMiA5JkWl3uso38daLkQhxjJlfmULZUmKcHcQS2RXbxT3 NZUUibOrJ1sVKvCnMFeuMww+o4xLJA0T164Zk2qvHHyLrsl+32/c7Lh7xXI1OvpyviNA G/GlJ0p9JqqNgNO/DKs+6FAJRG3mCZzHqsNCcbWZ2RN+kVXZgn20H+kB3zR7/POJIMqQ 3pDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RxyA+IzO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id oo20-20020a05620a531400b00767d5b81886si1346568qkn.458.2023.08.18.10.14.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:14:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RxyA+IzO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX323-0008O5-Oo; Fri, 18 Aug 2023 13:13:07 -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 1qX321-0008LE-Lp for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:05 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31y-000873-Bz for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:04 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bdbf10333bso9527515ad.1 for ; Fri, 18 Aug 2023 10:13:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378781; x=1692983581; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ataiAyODkAIfirPwE5L7zXmqt5E+aKGaPeIxcvvLwCA=; b=RxyA+IzOJkq5H4JqMH+nJeDa8c4Gpswj3vP2L82POTv4+jGyKA4rJwMQKLVgN+CoFj gLRRG7Spfpw6E7ACF/lUCHXZz7KF/Zqo+WYzfcGRHF6nXOaEo5V7kJlUR8Ap7YpWp8i8 PgD+WYQ8rkF9RJohhWglXkTs6Lsf9L+lEcK6Mxi/THj6yBFx/CqzxEI+9Cfgpl6Enlga qfYmJ5/o20MURjxb4fXvWjWVz6a4zskBtzAAP6+sAVdX5IZw7IjXZuZyq3062t4ZCxh6 7/b3RArhUGZtAWGK4rmRU5YHcuYEDpbN7M2odWSHmAkQ1+dOU6O/JYh5ZxAADK+hHhHH rknw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378781; x=1692983581; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ataiAyODkAIfirPwE5L7zXmqt5E+aKGaPeIxcvvLwCA=; b=OYOtzLVOJ4d0I+DY7kAIUc4GkKoSsJrwu6g18Zlrvfi0/V+sbLJVNEWpKmR/5r+IPi j1GvkAc6pDZiqAsJ3NOKSgshnUGyLGAWSkxmjfg4L/6PI7F/Bx4oT37OXdQD156zeezS 3sxmGnksEsaPS0GDf5rKZedG+1307N1sOtIAz3L+itvszG3OwAoCzY95hkSa8tXkhQYe u6On8vsFcXabSDrfk2EowlXkpHah2b2rGL69MHrOl5wMo+UieCMNtWf1XQzbaCBSWCQb Mdryz3sLE4ILTpR5MHDplt23alWYDFVF13rFoPkP5IFhAov60Wi41Y/fcKnWe4pHgt0Q /ZGg== X-Gm-Message-State: AOJu0YyWW0jFSSuiLWHNp7U19UO5uD7AzVTD/zA6yS0fHATKbrrc1yV1 tIV71ck/j367yWqCvyFT2PpjKoYR1RejPyvQHIk= X-Received: by 2002:a17:902:e850:b0:1b9:cf52:2bcf with SMTP id t16-20020a170902e85000b001b9cf522bcfmr3268637plg.0.1692378781190; Fri, 18 Aug 2023 10:13:01 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.13.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:13:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 27/33] cpu: Remove page_size_init Date: Fri, 18 Aug 2023 10:12:21 -0700 Message-Id: <20230818171227.141728-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Move qemu_host_page_{size,mask} and HOST_PAGE_ALIGN into bsd-user. It should be removed from bsd-user as well, but defer that cleanup. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- 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 8f2d6a3c78..9fe4e70890 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -38,6 +38,13 @@ extern char **environ; #include "exec/gdbstub.h" #include "qemu/clang-tsa.h" +/* + * TODO: Remove these and rely only on qemu_real_host_page_size(). + */ +extern uintptr_t qemu_host_page_size; +extern intptr_t qemu_host_page_mask; +#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size) + /* * This struct is used to hold certain information about the image. Basically, * it replicates in user space what would be certain task_struct fields in the diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 87dc9a752c..1bf4616fa3 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -22,13 +22,6 @@ typedef uint64_t vaddr; void cpu_exec_init_all(void); void cpu_exec_step_atomic(CPUState *cpu); -/* Using intptr_t ensures that qemu_*_page_mask is sign-extended even - * when intptr_t is 32-bit and we are aligning a long long. - */ -extern uintptr_t qemu_host_page_size; -extern intptr_t qemu_host_page_mask; - -#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size) #define REAL_HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_real_host_page_size()) /* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */ diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index fdcbe87352..66575eec73 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -1025,8 +1025,6 @@ bool target_words_bigendian(void); const char *target_name(void); -void page_size_init(void); - #ifdef NEED_CPU_H #ifndef CONFIG_USER_ONLY diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index b2d4e22c17..d84558dd95 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -255,7 +255,6 @@ bool cpu_unwind_state_data(CPUState *cpu, uintptr_t host_pc, uint64_t *data) void page_init(void) { - page_size_init(); page_table_config_init(); } diff --git a/bsd-user/main.c b/bsd-user/main.c index 381bb18df8..3cb2b5f43c 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -49,6 +49,13 @@ #include "host-os.h" #include "target_arch_cpu.h" + +/* + * TODO: Remove these and rely only on qemu_real_host_page_size(). + */ +uintptr_t qemu_host_page_size; +intptr_t qemu_host_page_mask; + static bool opt_one_insn_per_tb; uintptr_t guest_base; bool have_guest_base; @@ -308,6 +315,9 @@ int main(int argc, char **argv) (void) envlist_setenv(envlist, *wrk); } + qemu_host_page_size = getpagesize(); + qemu_host_page_size = MAX(qemu_host_page_size, TARGET_PAGE_SIZE); + cpu_model = NULL; qemu_add_opts(&qemu_trace_opts); @@ -407,6 +417,8 @@ int main(int argc, char **argv) } } + qemu_host_page_mask = -qemu_host_page_size; + /* init debug */ { int mask = 0; diff --git a/cpu.c b/cpu.c index 1c948d1161..743c889ece 100644 --- a/cpu.c +++ b/cpu.c @@ -431,16 +431,3 @@ const char *target_name(void) { return TARGET_NAME; } - -void page_size_init(void) -{ - /* NOTE: we can always suppose that qemu_host_page_size >= - TARGET_PAGE_SIZE */ - if (qemu_host_page_size == 0) { - qemu_host_page_size = qemu_real_host_page_size(); - } - if (qemu_host_page_size < TARGET_PAGE_SIZE) { - qemu_host_page_size = TARGET_PAGE_SIZE; - } - qemu_host_page_mask = -(intptr_t)qemu_host_page_size; -} diff --git a/softmmu/vl.c b/softmmu/vl.c index b0b96f67fa..bc2aab9aaa 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2049,7 +2049,6 @@ static void qemu_create_machine(QDict *qdict) } cpu_exec_init_all(); - page_size_init(); if (machine_class->hw_version) { qemu_set_hw_version(machine_class->hw_version); From patchwork Fri Aug 18 17:12:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714668 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp629856wrs; Fri, 18 Aug 2023 10:16:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNalXzV+jp2lsdsDINCVTwbDEoZGU+t76lXLe0mW1fBos10k7q4AUTouCTdQt+sPFr725M X-Received: by 2002:a0c:e3c5:0:b0:64a:2b04:c10d with SMTP id e5-20020a0ce3c5000000b0064a2b04c10dmr4235172qvl.25.1692378985583; Fri, 18 Aug 2023 10:16:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378985; cv=none; d=google.com; s=arc-20160816; b=n/dOKvOsU2qCk8HjgxepEGzbTqkJOpUUboMXOqRBjXFqsgb4RXVFyhpWIBVwmjPOh3 pb3kUoT5mzV+CTiGevOR9+UuWD+lQRUckjf1E5ut98iCVihGbxuiSWV2ZyqIvfA7+7FW qewIHk4xuZlSW9tV32FfOw3hPbYOHkl5yJDcGtXLgvw4M0qzVyGvWe7TRmrdA78tWEji gQVbHDX7RJyE2BK8/mBl5ElqG/4gIdN+HZJ1bX00jkqYrISA6Oz3Dp+J9zvTKGHSYl6V Rm75hEXfOebVdK4blSWe202vXxsnCa7SPRcNCOesSSIfJhWTqc7YF2r5/KYJX3gT4Yfb LXKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=xRESX9nFR6tNCpUYhPFWnwcFBDJbo9xNbLHublG/Dkk=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=bm3/NaF6ueGD97f+lZT6Ht3sOPUIDWK2qo6d06S6k9f4fOUL3zYa2davqTHQ3ScvGE +yBFim7itUJxwBb/7xbFA8eD2mkKCekiC/dO2DoRWZ48h+ldhEqBlPUHzmlnmIUyzk+F bUysZvoXB32D0N9MOVdQClmZb6pNgocdbauHXs060wjHsaY3ZSzE0aPxdKqQb1nEm1OG 2Gttc96eStIBOGWbVC7mdQk8aNR+aJfj9nAig0sMpTghElsqBz4DnwNv9cz33ZezDgiX DXRKdIEAiMeZ24K8e+c1QC030ueYqP7lIGnSQmfEcm9xAzBmWEHux5O3Ud9tWHNh/9uB d0Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xxMLexHM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c23-20020a0ca9d7000000b0063c75fece4csi1515536qvb.170.2023.08.18.10.16.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:16:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xxMLexHM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX325-0008Qm-4p; Fri, 18 Aug 2023 13:13:09 -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 1qX322-0008Lf-4W for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:06 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31z-00087J-Gd for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:05 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1bc83a96067so8714425ad.0 for ; Fri, 18 Aug 2023 10:13:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378782; x=1692983582; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xRESX9nFR6tNCpUYhPFWnwcFBDJbo9xNbLHublG/Dkk=; b=xxMLexHMqP8i5m0FMT0NADayUZknlyJRIIYFL8eWEwXV6jJGdWRCS4sLu4DF/piUwz GbJTwGmIUiYDna90YiP4As0HNWz0SPyhdwOY6olF9PVFXucjjBqju/5qXXmgpPMAKZ2a wTsAOGAp1yCFkOwBfqathxMe4qkyr9DJVj6QiiyzkLO+VHSGGEQ0qClq8bAPCpeLjDg5 W54Kc7zPuhhXGEUbK8sn33i+mxyzH447Kgb9clvl5NHgR9JOWDkwUX3LCbI1dXylOz4v JxBSdJ40c6fKpo8qxTpHKT8W75OGtaERaLSthB6tQlKn80rZh4AjFY+y4/vUFFXozxcj RqOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378782; x=1692983582; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xRESX9nFR6tNCpUYhPFWnwcFBDJbo9xNbLHublG/Dkk=; b=N+KuRaKi7fHRNQUVDZblshYOfvFQSH+Qp6OrGtiGOlpmxccU/KWUv8BNI4IZgXEpk4 /bIjlPjNiQPcbzgBK5ctxgALscUzBIs6PHGyDo7mfBrO1mLj2YpS8dFh6mTS75NcU+6z 1UVJinQSVgnHSlks4wPJ9atSJkR0xy/Dss5K30MmSCMuHGaEGgqznfnH0Xzi+awS4V4j ywKkQxv9WTma/JhlhqVCUcUULRWSog0X0AIuq1gSx2D1tDv5/soRb1eCeK6q57sHb9WE otMBq3l8kPJJr6QEYRFO27ukE91x93s8lZGEDxLNVS1FAn5SmdZD4mM0lKs+haUQlfTt uvnQ== X-Gm-Message-State: AOJu0YyNhNrwT1q4tYEGUEROeJRDI2YlXrz+MX0LEs7uEcCmW/l3WJoK beWfpoh3iKy3fffHSKLiMWLh43FNTx+JhniR89Y= X-Received: by 2002:a17:902:e88b:b0:1b8:9ecd:8b86 with SMTP id w11-20020a170902e88b00b001b89ecd8b86mr4006618plg.5.1692378782039; Fri, 18 Aug 2023 10:13:02 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.13.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:13:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 28/33] accel/tcg: Disconnect TargetPageDataNode from page size Date: Fri, 18 Aug 2023 10:12:22 -0700 Message-Id: <20230818171227.141728-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Dynamically size the node for the runtime target page size. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- accel/tcg/user-exec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 4c1697500a..09dc85c851 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -863,7 +863,7 @@ tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, vaddr addr, typedef struct TargetPageDataNode { struct rcu_head rcu; IntervalTreeNode itree; - char data[TPD_PAGES][TARGET_PAGE_DATA_SIZE] __attribute__((aligned)); + char data[] __attribute__((aligned)); } TargetPageDataNode; static IntervalTreeRoot targetdata_root; @@ -901,7 +901,8 @@ void page_reset_target_data(target_ulong start, target_ulong last) n_last = MIN(last, n->last); p_len = (n_last + 1 - n_start) >> TARGET_PAGE_BITS; - memset(t->data[p_ofs], 0, p_len * TARGET_PAGE_DATA_SIZE); + memset(t->data + p_ofs * TARGET_PAGE_DATA_SIZE, 0, + p_len * TARGET_PAGE_DATA_SIZE); } } @@ -909,7 +910,7 @@ void *page_get_target_data(target_ulong address) { IntervalTreeNode *n; TargetPageDataNode *t; - target_ulong page, region; + target_ulong page, region, p_ofs; page = address & TARGET_PAGE_MASK; region = address & TBD_MASK; @@ -925,7 +926,8 @@ void *page_get_target_data(target_ulong address) mmap_lock(); n = interval_tree_iter_first(&targetdata_root, page, page); if (!n) { - t = g_new0(TargetPageDataNode, 1); + t = g_malloc0(sizeof(TargetPageDataNode) + + TPD_PAGES * TARGET_PAGE_DATA_SIZE); n = &t->itree; n->start = region; n->last = region | ~TBD_MASK; @@ -935,7 +937,8 @@ void *page_get_target_data(target_ulong address) } t = container_of(n, TargetPageDataNode, itree); - return t->data[(page - region) >> TARGET_PAGE_BITS]; + p_ofs = (page - region) >> TARGET_PAGE_BITS; + return t->data + p_ofs * TARGET_PAGE_DATA_SIZE; } #else void page_reset_target_data(target_ulong start, target_ulong last) { } From patchwork Fri Aug 18 17:12:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714672 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp630314wrs; Fri, 18 Aug 2023 10:17:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzN1YZ8IICPXAHcgAVGdfvch2LTQcv0s0KovmSFh1pEWPQ4Afl3ea6oku+f1ERmoppF3AU X-Received: by 2002:a05:6358:440a:b0:135:43da:b16d with SMTP id z10-20020a056358440a00b0013543dab16dmr4030140rwc.11.1692379029504; Fri, 18 Aug 2023 10:17:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692379029; cv=none; d=google.com; s=arc-20160816; b=hO1SnF6CnQ4QN15fIV5shA+zBCpsHWMWKoqybdJJgpW7kGwKgq7Utb8CMGhRVLNnxU yY12sccFZEDZ9qg8/Gu9Q9hzwk8T9vaqcy8GGUyW4s4hOcPA3GeGRRB33bQ4fRgMRgsg 3stCMoxqVGS4tOhD20KMIvTSPMMomlFkjFObDTmhZ46KPr7nNn1LpWSW/+tjuIfLReSn RBFoUkHeqwuh/z9SJgi9QCbFob2A3hJ/IUfTenSIj4U0aSawk3JzBkRCfOLjSjOrGuIw GLiIb/cRHfn1IWOvDHEw00wH94n0wLrj47ltRtyRGdkgKbyk7upVqBcsejZawOU/DT6Q Z4iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Gjb3/VxZ1+V+7wtutprokQqvAFJJgSE2zXjUQaXpThk=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=pcf47xfBdtHrDheGeHOHFfLblc0Ci56lJqQn4MR3g5bt797JHlbyhrzR2Uws5BuOP/ ZEHES/pV/A15iWae6DmMgB55jzvCEpmfWoBeiUFvTLZXGcqGvA1OI7JwaDedW24iPa8s fviGQrOxLyeQPo3S5Z/KrPhp4zjRVwJMTEC2h3OFDrE9UrbKo7gxYt6ecWqDSX+Uk/Ms OHUkUnobysN1AY6mHPwKO8jwnzIbhFE1rMyFN7tiG2nP/FUN1eQjfK/Zwm5q6cwdaIct pm/7kYMdxZWtZA9qhHRjBZZBE1u7j8ugXCjRZwMcBJXL0kzN65FSLogWifBQ0DnMlPHO n8vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kuEh4+Jp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id qq4-20020a05620a38c400b0076cbce19efasi1275855qkn.726.2023.08.18.10.17.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:17:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kuEh4+Jp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX324-0008OR-IU; Fri, 18 Aug 2023 13:13:08 -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 1qX322-0008Ls-BT for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:06 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX320-00087V-7v for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:06 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1bdcb800594so9297315ad.1 for ; Fri, 18 Aug 2023 10:13:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378783; x=1692983583; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Gjb3/VxZ1+V+7wtutprokQqvAFJJgSE2zXjUQaXpThk=; b=kuEh4+JpYpTD2nX3jTcmYmIBK4Ol079fEd+Rg8VYjlUXmu0EjcLNEADNKcQuiXW+OS Q4d5LE4HafACHHc+AjLcjRewUjw5/WZVrHvPBcwRWuWIwsazVJ9ZVpGjK48eZjQ8tQ0n ovx3a7bdRRaApix4Mrs6c3TcfbnWqa6m8LhLxzjvJlIU3XCCrLQEAzvZ9X1VS3lE1bpk oR0iBB1tbw8RmigtLebGjYPNG4LhcEiPsjv1HDmnArmia3bR3dsTJdTP8Po9xiBTU0Ji rZW9dpxjm8fFrmRJca1TBtTXz860EkWLTyuYZEg7OOTET8pQ6O1sKZZrnz08fA31lCxe bK/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378783; x=1692983583; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gjb3/VxZ1+V+7wtutprokQqvAFJJgSE2zXjUQaXpThk=; b=GK5eAdMR9A0LGSO/jsZBIsHhkrnvlN2BY5/CUzeua/zwkujHIHbyNhh2jwLLyAELna 6X35QgyAKfl0G0T+tby3A5PergAur4jTKQtjW4WIwxhw7X/DihxfmXM0Lc1R4e8m5JuG 5naYtXGANx/pJgYajOPKKZFx4Ppn6t8KB47LXKpdrRJ2t2h8J1aHmEeMeVFXxwGRYORP yJR+6Vhb6f8KgIkd9OdJ9h/TZ36GzI3HYfz6IrVT9u+AQsqVlisBC16vY31iXWtCAHkd a19fRsudGUFtAq24d7sqgExOpb5wJebMpGe6eOuY/bI0Uw2HPI8be1tCTavH2C3ocCKO hzCQ== X-Gm-Message-State: AOJu0Yx9gQu7DsVbS6UJ27w2m1Pef9jmKlG1AzRbPmythMa7xBdG3fXs tVVnCYX5HzpkVayU7Ys9rfjNsWWRhRKKwD32J5E= X-Received: by 2002:a17:902:7005:b0:1bc:9c70:b955 with SMTP id y5-20020a170902700500b001bc9c70b955mr3086081plk.28.1692378783022; Fri, 18 Aug 2023 10:13:03 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.13.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:13:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 29/33] linux-user: Allow TARGET_PAGE_BITS_VARY Date: Fri, 18 Aug 2023 10:12:23 -0700 Message-Id: <20230818171227.141728-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org If set, match the host and guest page sizes. Signed-off-by: Richard Henderson --- linux-user/main.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 3dd3310331..2334d7cc67 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -55,6 +55,7 @@ #include "loader.h" #include "user-mmap.h" #include "accel/tcg/perf.h" +#include "exec/page-vary.h" #ifdef CONFIG_SEMIHOSTING #include "semihosting/semihost.h" @@ -683,6 +684,7 @@ int main(int argc, char **argv, char **envp) int i; int ret; int execfd; + int host_page_size; unsigned long max_reserved_va; bool preserve_argv0; @@ -794,6 +796,16 @@ int main(int argc, char **argv, char **envp) opt_one_insn_per_tb, &error_abort); ac->init_machine(NULL); } + + /* + * Finalize page size before creating CPUs. + * This will do nothing if !TARGET_PAGE_BITS_VARY. + * The most efficient setting is to match the host. + */ + host_page_size = qemu_real_host_page_size(); + set_preferred_target_page_bits(ctz32(host_page_size)); + finalize_target_page_bits(); + cpu = cpu_create(cpu_type); env = cpu->env_ptr; cpu_reset(cpu); @@ -807,8 +819,6 @@ int main(int argc, char **argv, char **envp) */ max_reserved_va = MAX_RESERVED_VA(cpu); if (reserved_va != 0) { - int host_page_size = qemu_real_host_page_size(); - if ((reserved_va + 1) % host_page_size) { char *s = size_to_str(host_page_size); fprintf(stderr, "Reserved virtual address not aligned mod %s\n", s); @@ -907,7 +917,7 @@ int main(int argc, char **argv, char **envp) * If we're in a chroot with no /proc, fall back to 1 page. */ if (mmap_min_addr == 0) { - mmap_min_addr = qemu_real_host_page_size(); + mmap_min_addr = host_page_size; qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=0x%lx (fallback)\n", mmap_min_addr); From patchwork Fri Aug 18 17:12:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714649 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp628492wrs; Fri, 18 Aug 2023 10:14:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEs3aodxOxQMWrfNTR0UCjdoTphd6xXCMQqZmauhg32nyjvRJzoIChy5WKw6WpuKmFNfWbF X-Received: by 2002:a05:6830:1e49:b0:6b9:50a8:1e76 with SMTP id e9-20020a0568301e4900b006b950a81e76mr3321550otj.17.1692378860468; Fri, 18 Aug 2023 10:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378860; cv=none; d=google.com; s=arc-20160816; b=zJQ0DUsqdyDbo8oJU1cmMjLxS/o8C8PFe0s05PYq8HWpqt0jhMXjtbcl+gHIxRpS3E kgPdza4oyN2WE+oUXDpb1L3uhTrWlLSY1UxTkZ0KZcw92Br1mMq6Np4ZpqAPz+fg49Yv MSosmUXXl/KRm57RJKDRgfukRPqXdAt9EzKhn11bhYA/mt+R19a6qL8t19iEqni7YkK2 KfxXcC8XUigFdj9b5k8sn/v/0saHZbGC5+EeUQ4KkMUc86wp+34c9psgfWJp7N9aXFQj Baw1JWBX2aG1GawnBye/QTtrTnHtdZjYW424KGdew0cCIkOXErauORYRYWo+m8e0ULxM MmBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=vhJle2SLoLtjF46S9WwbX4E0SKnoT2uUHN79WdZXuqE=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=f5d+9+dQ9HoO1jfc5HVaF1RJ2aTdcmjNxAeGvie5LO19gnBct5JWq4UbmHlaK0a3W6 aDrWkv9awYSv/aDFLERQwiDfDkjdRTaKPlx2QyPPd4igu30yvnbJzFDSxBaRwTK3u4NP 6puG8vIQT7/u8Kf9eRpAaKaJ1MJjyHelN1s12j/Y0DP20Btn7mRqXN0BLdRIDCbtPdl5 M8Gd9n+P0ijbJPyeDQLP5RCpJpR40IXc9r2Fyp9yLS01yxt9gLf9kRZcBzZt7A+DIkfU sVX9NgWgV959xfp2TPBdqs2kTj5AWj2u2q7SMbnkta7vFj57CRSZ0wDwXJGA9JHWkjgF l/nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KZ976yVP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z9-20020a05622a060900b004009a86df69si1432052qta.712.2023.08.18.10.14.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:14:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KZ976yVP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX32b-0000ow-He; Fri, 18 Aug 2023 13:13: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 1qX323-0008Mv-2E for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:07 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX321-00087j-DZ for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:06 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1bf078d5fb7so9040535ad.0 for ; Fri, 18 Aug 2023 10:13:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378784; x=1692983584; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vhJle2SLoLtjF46S9WwbX4E0SKnoT2uUHN79WdZXuqE=; b=KZ976yVP4xOp4JFWPwsekBKbtE3bDi47WnvNsriLCvXaS0bEOaHpD60z4G+rA8aH1V A/K+gbc0wDElXTaoYq86mbMkB/6Rg6jaRkMMg5y4hk/+Pv3ME8p+46xQpKxvm8fUcO0a peFGDqg6QoOd0hQT1TUqz2X9UY+KieJmfZ6hAA5UAymPwYGkmt31EkFO/IDED8OW36vZ sya0J8up+SPh7JRVrCZAgCF48wD2UtKnZcvb8m/rgQOYWCzX5R9Nef4qaYjtZAIrEDfq p9ABUuNLKioZffFzYfUEmLOv4DHQRct9gAG3EFgrOT0bbaqKiQhchzl+Mk3FptuLIvGK PC7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378784; x=1692983584; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vhJle2SLoLtjF46S9WwbX4E0SKnoT2uUHN79WdZXuqE=; b=YQbMXrtFsDNVX+uOuvKZEUnL+jFU6iB+5GYyofTJs6a1de+3sL4tFFGmus5ne2t2kG ou5E2ch77VzdK9bOhzmv2vwCLUsuxKtAJ38rURZh0OvqnmPEZX4RJXNk5p4laZ817841 gcoEe0zohuCD0uQ/MJJLsmLdO+7gLyi3apQ2Toq1S1pd3XNLfQjBr4o+J3hFWUQQiAl7 oaoMhXswmphtaucaDU3SEzEH7QDoYWepkTWZV5uAcZP2NP99SKuzUDYu9O3khOiOgn5D Y44r8pFtHwW96rrLnIXUa8akH1NwG3sZO5gHzDnSWy8qJbERrPnuitaij1bR/owW8cky rTXg== X-Gm-Message-State: AOJu0YzdrLkrj/klXIFIs5RPSF9xVXq2g67AxhmmommEjyPb/ymTfCN7 K8jfRzRjAOA+eywOUFCZ20Xh93IMKtoMwKtvraI= X-Received: by 2002:a17:903:2448:b0:1b5:561a:5ca9 with SMTP id l8-20020a170903244800b001b5561a5ca9mr3395672pls.50.1692378783729; Fri, 18 Aug 2023 10:13:03 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.13.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:13:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 30/33] target/arm: Enable TARGET_PAGE_BITS_VARY for AArch64 user-only Date: Fri, 18 Aug 2023 10:12:24 -0700 Message-Id: <20230818171227.141728-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since aarch64 binaries are generally built for multiple page sizes, it is trivial to allow the page size to vary. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/arm/cpu-param.h | 6 ++++- target/arm/cpu.c | 51 ++++++++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h index b3b35f7aa1..7585a810b2 100644 --- a/target/arm/cpu-param.h +++ b/target/arm/cpu-param.h @@ -19,9 +19,13 @@ #endif #ifdef CONFIG_USER_ONLY -#define TARGET_PAGE_BITS 12 # ifdef TARGET_AARCH64 # define TARGET_TAGGED_ADDRESSES +/* Allow user-only to vary page size from 4k */ +# define TARGET_PAGE_BITS_VARY +# define TARGET_PAGE_BITS_MIN 12 +# else +# define TARGET_PAGE_BITS 12 # endif #else /* diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 93c28d50e5..cb05f7a8a8 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1586,7 +1586,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) ARMCPU *cpu = ARM_CPU(dev); ARMCPUClass *acc = ARM_CPU_GET_CLASS(dev); CPUARMState *env = &cpu->env; - int pagebits; Error *local_err = NULL; bool no_aa32 = false; @@ -1953,28 +1952,36 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) !cpu_isar_feature(aa32_vfp_simd, cpu) || !arm_feature(env, ARM_FEATURE_XSCALE)); - if (arm_feature(env, ARM_FEATURE_V7) && - !arm_feature(env, ARM_FEATURE_M) && - !arm_feature(env, ARM_FEATURE_PMSA)) { - /* v7VMSA drops support for the old ARMv5 tiny pages, so we - * can use 4K pages. - */ - pagebits = 12; - } else { - /* For CPUs which might have tiny 1K pages, or which have an - * MPU and might have small region sizes, stick with 1K pages. - */ - pagebits = 10; - } - if (!set_preferred_target_page_bits(pagebits)) { - /* This can only ever happen for hotplugging a CPU, or if - * the board code incorrectly creates a CPU which it has - * promised via minimum_page_size that it will not. - */ - error_setg(errp, "This CPU requires a smaller page size than the " - "system is using"); - return; +#ifndef CONFIG_USER_ONLY + { + int pagebits; + if (arm_feature(env, ARM_FEATURE_V7) && + !arm_feature(env, ARM_FEATURE_M) && + !arm_feature(env, ARM_FEATURE_PMSA)) { + /* + * v7VMSA drops support for the old ARMv5 tiny pages, + * so we can use 4K pages. + */ + pagebits = 12; + } else { + /* + * For CPUs which might have tiny 1K pages, or which have an + * MPU and might have small region sizes, stick with 1K pages. + */ + pagebits = 10; + } + if (!set_preferred_target_page_bits(pagebits)) { + /* + * This can only ever happen for hotplugging a CPU, or if + * the board code incorrectly creates a CPU which it has + * promised via minimum_page_size that it will not. + */ + error_setg(errp, "This CPU requires a smaller page size " + "than the system is using"); + return; + } } +#endif /* This cpu-id-to-MPIDR affinity is used only for TCG; KVM will override it. * We don't support setting cluster ID ([16..23]) (known as Aff2 From patchwork Fri Aug 18 17:12:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714662 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp629570wrs; Fri, 18 Aug 2023 10:15:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9wxlBXFpp50b5aG1unTQ76MLx8z+fC5aSDtEP8Xx4aB3BkMqkGSdzwzTveO0pEc/n/1/l X-Received: by 2002:ac8:5c07:0:b0:400:9f2c:1211 with SMTP id i7-20020ac85c07000000b004009f2c1211mr4430235qti.29.1692378956402; Fri, 18 Aug 2023 10:15:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378956; cv=none; d=google.com; s=arc-20160816; b=FnrOis9ZS2taXQX4ou4ttfCf8hkGuXP/uTTMzE2AuW0Bn1A1eymoDMyqTpzIthnIqJ /0NZOIi50QlLifE6gLhXvZQpKA3BFtx8UgrYtFm0m7M+esDzGURFr+IE9cH6V959v2DX hKgHcbIVEMDcB75K8lpkmjRiLAjtaN3aKnuC1/ODw2quQm+LJlF5DLFuF0PPrPhcDi8/ kE6CGm3Cqs1rDzMwSpweQVzEWNkFubUHvnMroJO4rVZv2CKwGcPVV8XRS7UzWkKh+8wu 2b3aQxctd4rV1Q1QmmDx7KNVT8IRZlGCHsIekirQyaO1cQ9GtERqhzNw9+KhHLDw5Mzz VpWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=sLGhrncusZ++ow/925hmU4zhHqvG6lKeFI4gVIL5/yk=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=bqoKsjlT+5hCyOsd26R1vFr3UJIhgG4Hkb4R3iqVw1HdGR1BygBfYwemsJU1yv6FeX Q4OBkvsVP2GXdziUb8WfmFhukQ9tZCgtgLCw3y90t32KrLSBx1DhAxYy1qvyPTB7ZiAT Nn+gj90Ee2129FSFh1NDvypPxsDzL0hS0pFFTX6JBdxg3l8K1N2f5iDTc+wE+FZwLwH3 Sivvc7QbIt0HzaYqx6E5OTvZq0/13sY8BeuotImVgP4CVt7vln2Jti4xp+gmywXagZdK /BcPrL/c2y8preA6lwkSVNuswSjDGFJbL99Q0/66v8QiVclqZArp+pnpdpSu3wurRDYX Y6ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Uu32AVqG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h6-20020ac85846000000b0040fd23153e3si1484004qth.68.2023.08.18.10.15.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:15:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Uu32AVqG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX32M-0000CK-OG; Fri, 18 Aug 2023 13:13:27 -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 1qX323-0008NN-E8 for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:07 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX321-00087t-WD for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:07 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1bf1935f6c2so8162975ad.1 for ; Fri, 18 Aug 2023 10:13:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378785; x=1692983585; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=sLGhrncusZ++ow/925hmU4zhHqvG6lKeFI4gVIL5/yk=; b=Uu32AVqGVSodcZ4gTPPNa+hoE936Q2BEYSSS1WOrB/yyKLTN5a0Bsp8sBCHj8h6Xze PWpfhGA75s9NlaOr3elP8PfD03chJYT20z/yA1tEYUpXO6G0nlkD4rkcr5w5PdBA/bmh ZXUcuqd1l+9g69imzYQrwd80Q4WmHSW8IlcK5Hj/kLwnRfQEJsi2YyLf8Q4dgtsxzBWz NpmdgSmzeK3uvqARdBMraA8Ds7LtXbHlRoLln90yt3qKgjza+MTYZFGUT3YzJ8WzTXcf Mowu57GqTpbA/ofF8RfrT2OLRmWJH9AhOToZJ4oaQd4TZ0HnUa9wk8USVSxsI/QgbW0U oxNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378785; x=1692983585; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sLGhrncusZ++ow/925hmU4zhHqvG6lKeFI4gVIL5/yk=; b=BuZ7Stpf0awMb9LxHiIpeByl6lUt7b3A3xZrPuxPm6aucRbLL59JpvrZCdJPGvc4qO LmCUJ1RLlvj3xCEz1CmU3GJ9cxiXp3pl/o3IbOU6nNO02hr570hGf5j0bF/mkxajucHi yJFHtgEea9mChivJu8WYtfMYwWXtJDs+V2X9mnqEDi33vxf5VF5PFYqbhjQOfpahsdje XWnV6pzIF0K2wpTCXuI3tMaN4lv7YJDziZ1UPhu3YVRwGEn4iVj0PRjSWbfEDNuswZJN 7S4b6Tsib2loils/OPh5Nrxt6B6UYXT68mULBoKu9bNg2huP9unD2Ln2WKB/fFVmhLMj 5P2Q== X-Gm-Message-State: AOJu0YwR3QKR/RftCn2gYnzY/LQq8t9dazCTnvEQdw3ASc65wHvz0nEE I5r06LJrbyyy6cLjJYd35cbVhjX98/I6wME0nRk= X-Received: by 2002:a17:902:cecf:b0:1b8:8702:1e7c with SMTP id d15-20020a170902cecf00b001b887021e7cmr8096048plg.33.1692378784723; Fri, 18 Aug 2023 10:13:04 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.13.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:13:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 31/33] linux-user: Bound mmap_min_addr by host page size Date: Fri, 18 Aug 2023 10:12:25 -0700 Message-Id: <20230818171227.141728-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Bizzarely, it is possible to set /proc/sys/vm/mmap_min_addr to a value below the host page size. Fix that. Signed-off-by: Richard Henderson --- linux-user/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/main.c b/linux-user/main.c index 2334d7cc67..1925c275ed 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -904,7 +904,7 @@ int main(int argc, char **argv, char **envp) if ((fp = fopen("/proc/sys/vm/mmap_min_addr", "r")) != NULL) { unsigned long tmp; if (fscanf(fp, "%lu", &tmp) == 1 && tmp != 0) { - mmap_min_addr = tmp; + mmap_min_addr = MAX(tmp, host_page_size); qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=0x%lx\n", mmap_min_addr); } From patchwork Fri Aug 18 17:12:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714648 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp628456wrs; Fri, 18 Aug 2023 10:14:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1/gZRLnGoXrNSoykxHFUPISvtCO3J52JHKY2bvHOtcb6zvc37fd5Ul73t4gQpvQGbSRAG X-Received: by 2002:ac8:7dc3:0:b0:403:f38d:26f6 with SMTP id c3-20020ac87dc3000000b00403f38d26f6mr3951692qte.27.1692378856633; Fri, 18 Aug 2023 10:14:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378856; cv=none; d=google.com; s=arc-20160816; b=NFcVNlBWHbnQjHvHx/zCFDokQnZ5O4fICHVBNEAaxxIw0gr5JsRIUvz2nW07LER5cN 1GS6NGnblDkcXe04sQ5pG/v/8VIimn2opaeRikBOkTRv4xNmMpvhmZK8TjBEk9gqnWq3 NrBKqKwLyMphIcbURJd/IjL8XnJlVDrYa7nvDNR1M99FLolnCeZe+SIbNyaULtiHWiDi R06A+GPCbHTqJ8axW6ThgTEC7f8WhHCYt3n7uHhvhnHxspBF/L6+pv29m1hkb65uDFSt KGfv4RaBKXww4/fIzKvXy62npv+8a5QhOzDPteHqmCn3DjbwVuYdDD9WUrDrd0f8iAQs azmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=eX7UbTtp2FKEl6qFq7PUJtVbZ6Ita44vPDDEXKDHPg0=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=A67ZvkdMS+t2yW1WDO2IygTBFHIK2mhJD6S8r4PRvfsJEEcArBCINKlila0k7exyG3 +Ms45sewo7enn7M+R8aIttptng/4n3iJ1X9q8oqOHsFvxw2/u5/xFQ9e4Qq76JeeRHwU 9hZNv1VzRh2sjn6yfxOTmMHAd0rIung7K11Nd2Q+ILdlGQDSr0TaqoJwv7wTVc3TnlWe asaS3NEnrs2toFE3gpAIT97j03+vzAMdzBkvB9VNVhK0WCBKYbINVqxEuzUvCTIHWGKY Yspro3vPPdBvtR85mdJi1JrbtfcJpLs2/ibQx5AvQXC1KdluLKc/DI4T5rgf/AHcyzKh 2viA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lVT6TDsv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w21-20020ac87e95000000b0040357313971si266039qtj.662.2023.08.18.10.14.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:14:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lVT6TDsv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX32H-0000C4-9G; Fri, 18 Aug 2023 13:13: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 1qX324-0008OG-5Y for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:08 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX322-000888-Nu for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:07 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1bbff6b2679so8857105ad.1 for ; Fri, 18 Aug 2023 10:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378785; x=1692983585; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=eX7UbTtp2FKEl6qFq7PUJtVbZ6Ita44vPDDEXKDHPg0=; b=lVT6TDsvgBeXc9GhiloNeJDVsWw8NpnT5ahjvF0tncObtjjwI8wL3ft22Tp6RA82i8 8+OIrXvRiw+6dg9YwxogUdCfOVkip1YJRvOP28qyOUb7u7ePPGq94Jm7QzwYB2mS1For Ye0J/C8iWDZYTvoKn9k40AdpS0oBGAatTCG8PMPhcE+ljowk3WQnSQGhd6cqbRm+GDjs 60yKxMEl9CL3wlKATG10enN0ixpcfJg3+Ab8oPEHbZKgXENq26NTURhVSIhO/+5oF8AI GsT6hhLSN1VGCrEwALyexU+ZvTh/R+6zlYrLt6eE9dSvwMlR6NjPePwADJzCAw6C8zCz EeyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378785; x=1692983585; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eX7UbTtp2FKEl6qFq7PUJtVbZ6Ita44vPDDEXKDHPg0=; b=fkOET0yMUR1x5RhuEjXBwtAbUlJHqilS0Ue29O82orK+3DGKlHZK1Lam6NhqWkoF88 hmfhE0fyjVioGzEb0wG2WUx35E+nZKhO9IsDeU6vxAtrnN85l64WH09ow3eFcvRPy+gS MtiRvvuS6ye2OrHIXfEoSUV6vwwkeI3vW750O1oUk/tPxnE8D6S6fQ0ppinQ3YWaRoR+ I8dyC3iV9q5maluoWNQPrqbKw2v+CPjOQ6++6oYLsx702fErFP++vEd4aRMQyHUNJpYd VASGBxghK/675Kl7+2IwN8MCDquyKHFcASzCEKur86YPc58T3y9G7rUYrKDa33mSBzWO s99Q== X-Gm-Message-State: AOJu0YwN6A3kE0Q6TUxLLEnbmEqAdlR+H448NNIRzLO49EA1xmHmH6Ao EflskTyLUqJEPqaI+82n0j89sYGsrUdL9AEkaa4= X-Received: by 2002:a17:902:8688:b0:1bd:d141:f02d with SMTP id g8-20020a170902868800b001bdd141f02dmr2711161plo.68.1692378785437; Fri, 18 Aug 2023 10:13:05 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.13.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:13:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 32/33] target/ppc: Enable TARGET_PAGE_BITS_VARY for user-only Date: Fri, 18 Aug 2023 10:12:26 -0700 Message-Id: <20230818171227.141728-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since ppc binaries are generally built for multiple page sizes, it is trivial to allow the page size to vary. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/ppc/cpu-param.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/target/ppc/cpu-param.h b/target/ppc/cpu-param.h index 0a0416e0a8..b7ad52de03 100644 --- a/target/ppc/cpu-param.h +++ b/target/ppc/cpu-param.h @@ -31,6 +31,13 @@ # define TARGET_PHYS_ADDR_SPACE_BITS 36 # define TARGET_VIRT_ADDR_SPACE_BITS 32 #endif -#define TARGET_PAGE_BITS 12 + +#ifdef CONFIG_USER_ONLY +/* Allow user-only to vary page size from 4k */ +# define TARGET_PAGE_BITS_VARY +# define TARGET_PAGE_BITS_MIN 12 +#else +# define TARGET_PAGE_BITS 12 +#endif #endif From patchwork Fri Aug 18 17:12:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714655 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp628947wrs; Fri, 18 Aug 2023 10:15:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFBAzQ5n5B+aJAVomcROEVk6CQpDIbGB5Pv/iyLRSyWLBt7qLmYGB7eCTv1opi+/wdz3/D X-Received: by 2002:a05:6808:984:b0:3a1:c75d:b6ab with SMTP id a4-20020a056808098400b003a1c75db6abmr2810592oic.40.1692378901435; Fri, 18 Aug 2023 10:15:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378901; cv=none; d=google.com; s=arc-20160816; b=TY75v+7tiKrdzu2SLvGMKMONYhIxHXG2vpMUKOwusQwwXbjUqPzB/Odn14emNU+IQv BKdhJBOOkQ9KArwuOYf0GljqBC+yrlbiZ5Z5eW5QPPTk1jYv62TNXAJjlI79V7wHDujZ /92WDbR99OuOBgSLn+oKLlxYEnRi+inlTaM40iq3Pzj5hKeNfXp7SrG9OMqolQhjlo09 D8mlQJJ0N1MOWdu00kc6NFzju20MMhqnerKLr19dvSM05p9UqrQxz9nbk5GjzDkEXXUy Tqy9l7QxsHRLgFdcQd33NkiPOlYAmDMtHQB9lq3J0N2OFFfmtIEvZmLRpIyB7GIW+aOo 4W7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=UM3G3JW9WxcLT5Dzb3w4vT9giwKkE+uVqc4Wz3d/fxQ=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=DyVPv19p3n/hRq/nX00gzU6dQWHE8d+m3Pp76lewy3ZmQeX6kvVY659Dttp4Ocm+q4 a96JZwO6f0Kj4x2toBT6yaWMBpb5emg3q7+kKR1dF5KPvYEZAMe98TAf/NskJwSL+3pz iKumxrnPH3ovXgQZPUFtqlBYRr0MGX7TsHN4TNCZISinnVUq/ZvsYeQ/qnD7u5e0rUo1 lVpJ9VJn5zYW6URbyJQU/QebuQTjmHdzKi6kwRd03K78oHp1mwp6aGa4AuaXvdHOCkpG vVTMxVdmm5uXCziEUCFUP36s+OAR1FS3cD9fCjR9ZKwfQCAq0oBy3R+e+XzqU2zontfD E86w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZJqAMs62; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u3-20020a0cb403000000b0064bcf479953si873641qve.407.2023.08.18.10.15.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:15:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZJqAMs62; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX32e-0001Fi-Dh; Fri, 18 Aug 2023 13:13: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 1qX325-0008Pa-05 for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:09 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX323-00088N-GJ for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:08 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1bdf98a6086so9674595ad.0 for ; Fri, 18 Aug 2023 10:13:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378786; x=1692983586; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=UM3G3JW9WxcLT5Dzb3w4vT9giwKkE+uVqc4Wz3d/fxQ=; b=ZJqAMs62dxfOFUdRMgJhDC9NDpT+tox6sTixb3P7dzJMiM3+3AOzn0VSBnvzJDVD4n tjvpiIww4h9yYjli9rMxcnXKw7g5omkkJnmtNLrdMgNIifLfLqUzlXQMfuqoP/pnMMWw hZYtboIFCji5P1F553x5IUf7mV2+56Pa8xC0ZrcjwqxKgzGnQcuGzhp3RBkHIqegRUeR PqHpGFb3BdVmyd5dEe5FEkgpFIds4qNrd8qkHOVzlmLx8VSNte1uy0GbOQiCIW3IfDCH lp2gOoXzs30PCwAUVuF9DeLP6spOvmy8Szm9d+n3tn3OXGTgREMB5FQ4QoYq7EPX/lqv +xaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378786; x=1692983586; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UM3G3JW9WxcLT5Dzb3w4vT9giwKkE+uVqc4Wz3d/fxQ=; b=PiQ9YMz9gxdCgYtPSAZdClk7RTHNpCr5bgysRs6wPhRNm0Aw88qoTnbrXBjqY1Bg2L VXuStDZp2ESlq6/l1KP/p1popYkVTsRpR/9SnRm5IOayS65JL6A5AqEzvgdpsbGxrsqg 2HDJ+myz9a55H+ScdnjhsQdMlEjblpdjbtozCAyyLnHogrX/nEoIQ+Y5MMp0V8OFlQ1V elryymOGlcMmJ+r4DDa7bP2mI4Jl35V2BXmPbVZH+KitBQm/AIhDWxccoOF99YOTGr0u VErk2D+QHhya3OjqH0lr7s6tMf2e8W2k4iB2fW0Tk7rFGYB396TUMM+UeIloPlRmuiRq /nOA== X-Gm-Message-State: AOJu0YyMhSgoml9rihhJs4j9Uov/pqrhUf6MjimE4n72Ey0UuKjaD7ZZ R7B98hgazcadcQIYvdBd9/CFs6mY1MepH/ht0JQ= X-Received: by 2002:a17:902:c14b:b0:1bb:7d2f:7c19 with SMTP id 11-20020a170902c14b00b001bb7d2f7c19mr3143140plj.64.1692378786282; Fri, 18 Aug 2023 10:13:06 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.13.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:13:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 33/33] target/alpha: Enable TARGET_PAGE_BITS_VARY for user-only Date: Fri, 18 Aug 2023 10:12:27 -0700 Message-Id: <20230818171227.141728-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since alpha binaries are generally built for multiple page sizes, it is trivial to allow the page size to vary. Signed-off-by: Richard Henderson --- target/alpha/cpu-param.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/target/alpha/cpu-param.h b/target/alpha/cpu-param.h index 68c46f7998..c969cb016b 100644 --- a/target/alpha/cpu-param.h +++ b/target/alpha/cpu-param.h @@ -9,10 +9,22 @@ #define ALPHA_CPU_PARAM_H #define TARGET_LONG_BITS 64 -#define TARGET_PAGE_BITS 13 /* ??? EV4 has 34 phys addr bits, EV5 has 40, EV6 has 44. */ #define TARGET_PHYS_ADDR_SPACE_BITS 44 -#define TARGET_VIRT_ADDR_SPACE_BITS (30 + TARGET_PAGE_BITS) + +#ifdef CONFIG_USER_ONLY +/* + * Allow user-only to vary page size. Real hardware allows only 8k and 64k, + * but since any variance means guests cannot assume a fixed value, allow + * a 4k minimum to match x86 host, which can minimize emulation issues. + */ +# define TARGET_PAGE_BITS_VARY +# define TARGET_PAGE_BITS_MIN 12 +# define TARGET_VIRT_ADDR_SPACE_BITS 63 +#else +# define TARGET_PAGE_BITS 13 +# define TARGET_VIRT_ADDR_SPACE_BITS (30 + TARGET_PAGE_BITS) +#endif #endif