From nobody Sun Apr 28 12:32:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631847525704709.4401416132237; Thu, 16 Sep 2021 19:58:45 -0700 (PDT) Received: from localhost ([::1]:46318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mR45L-0000Zs-LL for importer@patchew.org; Thu, 16 Sep 2021 22:58:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mR43P-0006Or-5d for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:43 -0400 Received: from mail-il1-x12c.google.com ([2607:f8b0:4864:20::12c]:41499) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mR43N-0005mn-3P for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:42 -0400 Received: by mail-il1-x12c.google.com with SMTP id d11so4854551ilc.8 for ; Thu, 16 Sep 2021 19:56:40 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id e10sm2603738ili.53.2021.09.16.19.56.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Sep 2021 19:56:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VNnZYNNWkXZfPumYFKmw5xunCUfR3eo4wtv9cbIoG60=; b=SKSsnhPA4LLJgtyk3JI1AcTuNLxAVjcGcgMO9rEHh9rVMpvVRW7j4R5kWC7K9/cPTv eBHx+nuovVk/+jEwMYwxXOdp0cRL2jdXQ194pWyK9a6dZIndBlv2x7RB3BqUu7zaqnJL FhtNXPZ6Z+cIOPsR7HZi+PWGuJMXK6R9soSLKSu1OdmM2VAEy4Fl39pZyoU392MtVH9P YVa4GC3n09CG4Q4Ovc1RZQxJJFP35JSzewWtUMk1Lc018rImx2672NHkLZn4N1NlON+y 0CT+ktyF5s1KCtuL1EXeRzFb1lNN8MKBDGr3wDxfCxC7ICSIZvse59brnXuzKql/deVg 1uuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VNnZYNNWkXZfPumYFKmw5xunCUfR3eo4wtv9cbIoG60=; b=cEu7gJ1rBEHcB/HuyTKTMSsG54pt2qdzDjCp0xUb3ClJccoo+NNponpKB3AZgj0AB4 /mLAl+T665jsvA+x0Ak8Yf7VdciviGljx21n/vWUvhvP7NRugVd3AEcAVuQty537xl4V 4AXCmmBowXZATRGvbQrXLfwhe87qUvZgVwgt6P1A8VjyyOUjtVoHfUNCevJzbzn9vHdZ h32qgiQYHsrvYbbK5QOq7MYWFTlhWvdcEo/gSCbMQ9LtWEg7aUHiVEj156xPqnOJb1XR eseP4M0KtvSMgi3lH0JZJBiNWXeL5TOfAzBgbeyEj6cS56YiqCUFbi3ubwa6BxN1skUC kMUw== X-Gm-Message-State: AOAM533HFgmZ2XhEssnkgHYTzLcLYva+K40DZq1he+F1V8U01AsiFJic 6QAAZdaPatHlvoHa0sVsVc43YjTkK8lQ0YG1+Ro= X-Google-Smtp-Source: ABdhPJzudDLB0wvhn0RI/6wjTSiAE7RL8ZySclt7F1SwXefqC9sfNivALDwsr0pKe/gbbAJ1lfUA3A== X-Received: by 2002:a05:6e02:10c4:: with SMTP id s4mr5907769ilj.285.1631847399325; Thu, 16 Sep 2021 19:56:39 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 1/9] bsd-user: Apply e6deac9cf99 from linux-user (zero anonymous memory) Date: Thu, 16 Sep 2021 20:56:27 -0600 Message-Id: <20210917025635.32011-2-imp@bsdimp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210917025635.32011-1-imp@bsdimp.com> References: <20210917025635.32011-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12c; envelope-from=imp@bsdimp.com; helo=mail-il1-x12c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chen Gang , kevans@freebsd.org, Riku Voipio , Laurent Vivier , Warner Losh , =?UTF-8?q?Mika=C3=ABl=20Urankar?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631847526314100002 From: Mika=C3=ABl Urankar linux-user/mmap.c: Always zero MAP_ANONYMOUS memory in mmap_frag() When mapping MAP_ANONYMOUS memory fragments, still need notice about to set it zero, or it will cause issues. Signed-off-by: Chen Gang Reviewed-by: Laurent Vivier Signed-off-by: Riku Voipio [ bsd-user merge by Mika=C3=ABl Urankar, updated for untagged by Warner Los= h ] Signed-off-by: Mika=C3=ABl Urankar Signed-off-by: Warner Losh --- bsd-user/mmap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index b40ab9045f..fc3c1480f5 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -180,10 +180,12 @@ static int mmap_frag(abi_ulong real_start, if (prot_new !=3D (prot1 | PROT_WRITE)) mprotect(host_start, qemu_host_page_size, prot_new); } else { - /* just update the protection */ if (prot_new !=3D prot1) { mprotect(host_start, qemu_host_page_size, prot_new); } + if (prot_new & PROT_WRITE) { + memset(g2h_untagged(start), 0, end - start); + } } return 0; } --=20 2.32.0 From nobody Sun Apr 28 12:32:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631847525689788.0395159195264; Thu, 16 Sep 2021 19:58:45 -0700 (PDT) Received: from localhost ([::1]:46384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mR45M-0000ca-5w for importer@patchew.org; Thu, 16 Sep 2021 22:58:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mR43P-0006Oz-C9 for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:43 -0400 Received: from mail-il1-x133.google.com ([2607:f8b0:4864:20::133]:44942) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mR43N-0005nN-B3 for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:43 -0400 Received: by mail-il1-x133.google.com with SMTP id x2so8734523ila.11 for ; Thu, 16 Sep 2021 19:56:41 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id e10sm2603738ili.53.2021.09.16.19.56.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Sep 2021 19:56:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V3kJ3rG5LvywxyPiAPSPaqcJeVXwF6oa43iLfreGatE=; b=8AqsNDsctC3Mo4aqSvc7Z6SHRbXiFPpQtDrRz6HKiVR1VrSKBj1M0PEHrsP9rdTXwi O7AZ9UQHFRLtakCIPzERQu8jWI/P8aeuKg8ClELMwe3+kYx45Q66JkwTVv0LbnbXHaUk K/tPYMdFeFH/yaeqi2jxnOlPBhn+g0NRLpOFgbwWAOzKkm/4S0HJUMdzGfERYZjZ84aX IHthTGLUwDzWVTdX75yrzh7n4WzM9OcbV8qmTuCATyav3SSjHLUGXr+hh8GFV3zVZd+R ykhaGT9p25cxJ2g+mQ9oySqmkXUFB5DUVDcDwuCSb+NSr/cfEhA7+hJsHh5KEB2i7bqx k0ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V3kJ3rG5LvywxyPiAPSPaqcJeVXwF6oa43iLfreGatE=; b=HZqGCrnv9Q6pCgOwyc3Zh4jLdXjknyEDUAWb8+oV1itYtXAN7JW3L1bJew3OAJYEcT 2Z4foabpTKeWCocbNCR/8iaQ1fSUQlmSdNw3u45JWYNkgWToSTJ7M7/qzla6YTVgORVD 00VYA1TTds3BSmr7h8Ck3s9jOpL19R9zXMZDQTO/E7z+kZsXL3ow7LVWoLtOfmCAHIHQ 0ZS8Y3L/FidkhO/KJLxsffu03NC9dnQRvGVO/D0QMvJp/iKfpH5rTtefv+qJDeVc4XtY h47TSkgMvKjbBJf+xwx9Py+YgG8SUXmH7F7hBrqTUYaxF1Ml6mOTdfQ1+pfy5KvIED/l vhLA== X-Gm-Message-State: AOAM533Smlpn2J2Fm/e6XMscD9ayuaNRUkYtNthYX2xY7sY/lALOi6xC hL83sdyO3AtfvYmPjGN7cGObtXnsuWcH4J33Sbo= X-Google-Smtp-Source: ABdhPJwO7e3XRcgT8n7eEl6UsCnrqQilJdcohhjBpSxim11yqLfUtJ/jQGWe5RUGArPBIkUBcss3OQ== X-Received: by 2002:a05:6e02:ecd:: with SMTP id i13mr6210631ilk.143.1631847400070; Thu, 16 Sep 2021 19:56:40 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 2/9] bsd-user: Apply fb7e378cf9c from linux-user (fix FORTIFY warnings) Date: Thu, 16 Sep 2021 20:56:28 -0600 Message-Id: <20210917025635.32011-3-imp@bsdimp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210917025635.32011-1-imp@bsdimp.com> References: <20210917025635.32011-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::133; envelope-from=imp@bsdimp.com; helo=mail-il1-x133.google.com X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anthony Liguori , Juan Quintela , kevans@freebsd.org, Warner Losh , "Kirill A . Shutemov" , =?UTF-8?q?Mika=C3=ABl=20Urankar?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631847526318100003 From: Mika=C3=ABl Urankar linux-user/mmap.c: fix warnings with _FORTIFY_SOURCE CC i386-linux-user/mmap.o cc1: warnings being treated as errors /usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c: In function 'mmap_frag': /usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c:253: error: ignoring retu= rn value of 'pread', declared with attribute warn_unused_result /usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c: In function 'target_mmap= ': /usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c:477: error: ignoring retu= rn value of 'pread', declared with attribute warn_unused_result make[1]: *** [mmap.o] Error 1 Signed-off-by: Kirill A. Shutemov Signed-off-by: Juan Quintela Signed-off-by: Anthony Liguori [ Merged to bsd-user by Mika=C3=ABl Urankared updated by Warner Losh for un= tagged ] Signed-off-by: Mika=C3=ABl Urankar Signed-off-by: Warner Losh --- bsd-user/mmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index fc3c1480f5..90b6313161 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -174,7 +174,8 @@ static int mmap_frag(abi_ulong real_start, mprotect(host_start, qemu_host_page_size, prot1 | PROT_WRITE); =20 /* read the corresponding file data */ - pread(fd, g2h_untagged(start), end - start, offset); + if (pread(fd, g2h_untagged(start), end - start, offset) =3D=3D -1) + return -1; =20 /* put final protection */ if (prot_new !=3D (prot1 | PROT_WRITE)) @@ -593,7 +594,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, -1, 0); if (retaddr =3D=3D -1) goto fail; - pread(fd, g2h_untagged(start), len, offset); + if (pread(fd, g2h_untagged(start), len, offset) =3D=3D -1) + goto fail; if (!(prot & PROT_WRITE)) { ret =3D target_mprotect(start, len, prot); if (ret !=3D 0) { --=20 2.32.0 From nobody Sun Apr 28 12:32:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1631847713; cv=none; d=zohomail.com; s=zohoarc; b=n/z15farwCmZa6uxc03Jb0I2NhRDkKxegY/0JggUQamxh6Oi+E0WD2JNyyJaZtwLFgM32J5rJVKCWXISLsgGDFNYnLHg65TFSazfKwBkikwnZ1y13dsmJn5mjo26ELSrhhnHHBno9xZHqjIccWvIHl+XDJs5CpVNhHnpG1ffcxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631847713; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TL4QVglLwTwjmmK5iuIYy6RUoEGcOEGAZFpu/cA1g1k=; b=F+BWUHaT2gQaLhCbwBsN3uPnBgE0siRxmFuXsfqgGiD0pOC1k+Q5fWgTRC/n11xtM9MC+QxTq6UJG50Q1/gqyX7UHIBne9cu589i2gUAhw/8ZHulLV4o/b0FJZ+OFyIYDQVc+vOtMDtjhMEuB0W+awykp9svrpR1uYOQDYJHRvE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631847713975314.99517020752114; Thu, 16 Sep 2021 20:01:53 -0700 (PDT) Received: from localhost ([::1]:54144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mR48P-0005m3-0x for importer@patchew.org; Thu, 16 Sep 2021 23:01:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52744) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mR43Q-0006PC-3k for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:44 -0400 Received: from mail-io1-xd2a.google.com ([2607:f8b0:4864:20::d2a]:34555) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mR43O-0005o6-Cq for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:43 -0400 Received: by mail-io1-xd2a.google.com with SMTP id y18so10490183ioc.1 for ; Thu, 16 Sep 2021 19:56:41 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id e10sm2603738ili.53.2021.09.16.19.56.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Sep 2021 19:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TL4QVglLwTwjmmK5iuIYy6RUoEGcOEGAZFpu/cA1g1k=; b=GTm0SByp4Q3VEIdKpQih2qoY1vKxe0rXrwQF9hViviEtrrS0ivrH9wDEADpeyz0+79 /ValKvaJgipLOliv6HPjq66bAVRnXTmmYZ6d6F4FZSCnThq/XwA/U3jzzCvpr1SNAzCZ VHWjQ02nRXMfUMEr5szzLL0E2nCzKtNmCoLO8cw4UW7KnD88q3PJU7SzgCrZYWTVJCXr ZKXjIF/D7OiV4KwsCnBs5O7iqrIJgXSGuqOmH3Xu9o1LCo8AMyz/ZhXsHiGV+y1zIbC4 FSczR/J+2arQG3aNIquD4Hqlv/TY/dS9+wtPmaKuPym+A5r+b0OyROHFj+JpT/1VIf2v JXaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TL4QVglLwTwjmmK5iuIYy6RUoEGcOEGAZFpu/cA1g1k=; b=NVFB/Ehh6psPgtxP75JHcPmAdZ7mgTau6xuVhz/tKwz7PxUiL2QHFfiLyIfPmVQOs9 YJkKM/JbgsjTDSwq+G6pK7U1FHim+fCPMUflhTaDlZtCd3p8M1qP3oMlZmbZ4hyB8lVK RYOImcFxAtQ4kJPxalhGSYnc/zeXK2XZyxYLFnE/g2r+5djJcyPuPnGe3ICdhNrED8Zd 1hAlgs30CCmjPTW/yr2eQAviO6j8lPUDjUBjGH7sfrsBhR2+EchQU5kwg0XHQ1KLcHcI VJlivOtd7ao9uuL3U5rjZ8JMeN4xJ3fVEzxbZe+MJLmCGyj1S8QIjvoqN7OiVkR/KuAc 7AyA== X-Gm-Message-State: AOAM531El0/WwDwJ1jmwoQe9yF/JdonBb/FHu/0SJy59BidkJOf+73TD xjbufxB2Nr28Ry5g9bJtceVWi/Gd5w8k6jFKJvU= X-Google-Smtp-Source: ABdhPJye1h+OlVPoKyE4edjIQjojfa5Vf9mEz5i8AgYH3sJ0KUaddXkhreAFIdJctj7bE0inaxasCQ== X-Received: by 2002:a02:716b:: with SMTP id n43mr6909658jaf.14.1631847400778; Thu, 16 Sep 2021 19:56:40 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 3/9] bsd-user: MAP_ symbols are defined, so no need for ifdefs Date: Thu, 16 Sep 2021 20:56:29 -0600 Message-Id: <20210917025635.32011-4-imp@bsdimp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210917025635.32011-1-imp@bsdimp.com> References: <20210917025635.32011-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2a; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2a.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kevans@freebsd.org, Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1631847715967100005 Content-Type: text/plain; charset="utf-8" All these MAP_ symbols are always defined on supported FreeBSD versions (12.2 and newer), so remove the #ifdefs since they aren't needed. Signed-off-by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- bsd-user/mmap.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index 90b6313161..c40059d7fc 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -285,13 +285,9 @@ static abi_ulong mmap_find_vma_aligned(abi_ulong start= , abi_ulong size, wrapped =3D repeat =3D 0; prev =3D 0; flags =3D MAP_ANONYMOUS | MAP_PRIVATE; -#ifdef MAP_ALIGNED if (alignment !=3D 0) { flags |=3D MAP_ALIGNED(alignment); } -#else - /* XXX TODO */ -#endif =20 for (;; prev =3D ptr) { /* @@ -406,22 +402,18 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int prot, printf("MAP_ALIGNED(%u) ", (flags & MAP_ALIGNMENT_MASK) >> MAP_ALIGNMENT_SHIFT); } -#if MAP_GUARD if (flags & MAP_GUARD) { printf("MAP_GUARD "); } -#endif if (flags & MAP_FIXED) { printf("MAP_FIXED "); } if (flags & MAP_ANONYMOUS) { printf("MAP_ANON "); } -#ifdef MAP_EXCL if (flags & MAP_EXCL) { printf("MAP_EXCL "); } -#endif if (flags & MAP_PRIVATE) { printf("MAP_PRIVATE "); } @@ -431,11 +423,9 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, i= nt prot, if (flags & MAP_NOCORE) { printf("MAP_NOCORE "); } -#ifdef MAP_STACK if (flags & MAP_STACK) { printf("MAP_STACK "); } -#endif printf("fd=3D%d offset=3D0x%llx\n", fd, offset); } #endif @@ -444,7 +434,6 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, errno =3D EINVAL; goto fail; } -#ifdef MAP_STACK if (flags & MAP_STACK) { if ((fd !=3D -1) || ((prot & (PROT_READ | PROT_WRITE)) !=3D (PROT_READ | PROT_WRITE))) { @@ -452,8 +441,6 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, goto fail; } } -#endif /* MAP_STACK */ -#ifdef MAP_GUARD if ((flags & MAP_GUARD) && (prot !=3D PROT_NONE || fd !=3D -1 || offset !=3D 0 || (flags & (MAP_SHARED | MAP_PRIVATE | /* MAP_PREFAULT | */ /* MAP_PREFAULT not in mman.h */ @@ -461,7 +448,6 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, errno =3D EINVAL; goto fail; } -#endif =20 if (offset & ~TARGET_PAGE_MASK) { errno =3D EINVAL; --=20 2.32.0 From nobody Sun Apr 28 12:32:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1631847815; cv=none; d=zohomail.com; s=zohoarc; b=F6xoT9mdzADWEzjCWQYrQbjB5qWXVfsJnONpFvh3qo5i/Nvwq6KZKfxcAcXOSBPxXmd+S2+ARW87lK9vyyxGgRTwLbWV3WC8YkVZNdrrRjnm0sWuCcFQ+HXUodLwWTVEdfvtTmBBio10gyuYwRunpfSg9eUkWZQvUGI36WwBZqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631847815; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Bz9xxzOHeyZagtkOxaSrxkXtiVjb/9po0iv6mA9969Y=; b=Q1AlyWj8NSMrruinQSUTjWC5Gut6tro5mPQPCOp+lNifubUjy/T/MsXGm8TsPqwUcBVJg6vUuJ/2v7Obomawx3VCBZn3xkGIordkU0BPeD97CvtV1O7Wt/bfP+4a6hcohLinMq9GWh9rKqIo4Q3DaTbh3mPs93GSEc5fyM3RFsw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631847815787471.72108563917357; Thu, 16 Sep 2021 20:03:35 -0700 (PDT) Received: from localhost ([::1]:60630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mR4A2-0001k1-Qi for importer@patchew.org; Thu, 16 Sep 2021 23:03:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mR43R-0006SJ-Q4 for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:45 -0400 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]:46901) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mR43Q-0005rI-Fb for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:45 -0400 Received: by mail-il1-x136.google.com with SMTP id h20so8730959ilj.13 for ; Thu, 16 Sep 2021 19:56:44 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id e10sm2603738ili.53.2021.09.16.19.56.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Sep 2021 19:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Bz9xxzOHeyZagtkOxaSrxkXtiVjb/9po0iv6mA9969Y=; b=e2rwnNAeeHEiHHAEknTuo+PWA2/ILK05wd+vEUCCuasQ4LIvhsu0jWmWS+4gHTnZ2j 6pKB3MpARQWwL6lGnAzm1rFZtpLy7/kBz8qz529GDTb+XykxXkMw8qa2VfLDd6CDJxOj PvtcZKRGWQ5l3eXyKJEDce+y0SU/BfGzVTxCZ/PMlU3iKpw/HJHLad3T73aDwOWPhDDF zD1nCScZK59tFKBaHc0BG/O8uAkSqTfWsJN6jLppk/ignletezyxm8ixhUPjbi/HlU7a jSHcGWmg/pEnyWwHGI9ccLmJR8M/8sxmtnZ0gQJlNni9RvaK0RTh2kLW5zTPnlIek0o4 ThgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Bz9xxzOHeyZagtkOxaSrxkXtiVjb/9po0iv6mA9969Y=; b=yR2/1uhvfJKwnaOQsP2OuUd5kL3QK5SDxCbU+X+9deuX+5XHmkjkzWA57GZMto17yF TpGMDVCJ1z9XzswBSVs+JYvvMjj9JPfxumbhwrmRR66qgabvfJTPkgyIEs+9x7RJTBvT /MF53rqrkITRKNBefd7G4P0ijqzMAO3SFU8VFuyCfh14F60LT46r55hT8IZvCcEyFQlB vr0xVAA20jWc6vf3SmkKaMGLKIXE49GmtkgLsC4Ep2rlTidJO054MF6eCZH6vbDCE3DN UQNWOAcRxn4DhAYQIihasQwHCvmW4r/Y3cfgXReaNWYno5froyJkMI87oMIhU0u438Mn LRxg== X-Gm-Message-State: AOAM530gWrGuiUSYiS7gSasVogav8q7v6Q2qsQ+lwaHCChTSHN3qh1HB iluLpyOIVtEvHtmb8YEbIb1sFeUy9P2a/b38xOA= X-Google-Smtp-Source: ABdhPJy5BipFUox6GNOw2IxuQZE0ROZLaQS1mIhqM8j9bl2IxquV5B2GuoawSfgwgILOd2CeyWhmEA== X-Received: by 2002:a05:6e02:f13:: with SMTP id x19mr6406915ilj.216.1631847401538; Thu, 16 Sep 2021 19:56:41 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 4/9] bsd-user: mmap return ENOMEM on overflow Date: Thu, 16 Sep 2021 20:56:30 -0600 Message-Id: <20210917025635.32011-5-imp@bsdimp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210917025635.32011-1-imp@bsdimp.com> References: <20210917025635.32011-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::136; envelope-from=imp@bsdimp.com; helo=mail-il1-x136.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kevans@freebsd.org, Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1631847817043100001 Content-Type: text/plain; charset="utf-8" mmap should return ENOMEM on len overflow rather than EINVAL. Return EINVAL when len =3D=3D 0 and ENOMEM when the rounded to a page length is 0. Found by make check-tcg. Signed-off-by: Warner Losh --- bsd-user/mmap.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index c40059d7fc..0acc2db712 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -454,11 +454,18 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int prot, goto fail; } =20 - len =3D TARGET_PAGE_ALIGN(len); if (len =3D=3D 0) { errno =3D EINVAL; goto fail; } + + /* Check for overflows */ + len =3D TARGET_PAGE_ALIGN(len); + if (len =3D=3D 0) { + errno =3D ENOMEM; + goto fail; + } + real_start =3D start & qemu_host_page_mask; host_offset =3D offset & qemu_host_page_mask; =20 --=20 2.32.0 From nobody Sun Apr 28 12:32:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1631847713; cv=none; d=zohomail.com; s=zohoarc; b=IfXvZRgQs2UCsK2UYFwBv7qn13L3FY08FqlWreyIOexIl+S7sYjN3nieIXeUfNzWtCq/pziNHvgMrE0EhZ5aRXpkB96y9nRRGWKaREtdqtRAMDiLPBloiMXoTwiCu5UlX38QW4krlmjT3MUVWo/0elFpihF6zS50OKjVllhsZZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631847713; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8Vzgoo2caIWheChlxtQetZ/F+1IpsE33ClusX3+oSXU=; b=mBh6XdIrbpSEtMKtD06um9AMkseP5CvgAdcXxG6zz2wsQzeuU/9ju6DVihatWyOruGR+PoslXlxG+lHJfqokvtkr4JbJ0OR6el3GMkPzY3q9LmqM6tIkgqoaRzIqLjBm4QCD5h1MbkRljFwj2D+8c2q7aS0do2ECQ/XveOeCUFo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631847713515586.1350497057008; Thu, 16 Sep 2021 20:01:53 -0700 (PDT) Received: from localhost ([::1]:54168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mR48O-0005n3-G4 for importer@patchew.org; Thu, 16 Sep 2021 23:01:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mR43T-0006WW-63 for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:47 -0400 Received: from mail-il1-x12b.google.com ([2607:f8b0:4864:20::12b]:46891) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mR43R-0005sN-KJ for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:46 -0400 Received: by mail-il1-x12b.google.com with SMTP id h20so8730976ilj.13 for ; Thu, 16 Sep 2021 19:56:45 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id e10sm2603738ili.53.2021.09.16.19.56.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Sep 2021 19:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8Vzgoo2caIWheChlxtQetZ/F+1IpsE33ClusX3+oSXU=; b=thQpduziTEbqNd3YyIRlPE7POUyRVqacoZkrqWkZJ7XZmOLB5BCs/1snLyekKMhcoN UTdbktoGJxujUyK/tBiBCc//EaHf0Nba3aQ35VHpkOfr+fUui6H/yS6x4n3/5qxm+V3/ LB/Q0mYF7+OTEoyHEOYzJUPhLbX1FPbISDKooxrAjXQseiOYjBIc1ogafUe3XXBp+VtH POhWLmy2xWanfYFHq/hO/Ojc9iNyoEKd76t+eBV1N1duRs05UT3l1WoMZPBBQGs4h7c2 ihj85PWAFTSsLnQmzQzWXaePILxZlsvzuDB+FltgtILbO9Pe10HCynwMxir9jRYNWIrQ wmsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8Vzgoo2caIWheChlxtQetZ/F+1IpsE33ClusX3+oSXU=; b=mjEsvBqiPPtIdD2bCF0TRoq+/qCL0VyFoxTA1LuAXnAL6wdu9hpTgyiERTmUy9EpLz j8vytT17o/1QE7gGjDVdka4CvzF245i+N5fezhcG5p8gBZf6OhZcEkOzl9cEqypgHNTk ttispJ7WPJdj3+nEaQ8iLOi5SUPbdR6lhnjm++7/IqjNYGkXFug/SP5pltbUIRdMBcyc 4RnicHYo4YeA5vGs4/Tj9mLCHDwQhoGdnEzSLIuTqV4vvccFsPrnucxINpmiNXzvaos9 JiGgvnyOTGhlYtJHZlpSI1BHYS+svzKZQg4Cg3A+EANNoxdAMp/kWlAPJA4sEwyxSGxL 6VSA== X-Gm-Message-State: AOAM533y9u5z1OPqkbF1cGtdK1KTvKMOXT8RsB63+5E6A7a9K1QZjRJy dw2tyizrjF2cazj49nulmY+eGOQjEoy9tOr5/7I= X-Google-Smtp-Source: ABdhPJzkooptEjMQsUMfWNb36euL3LdegO1TDugwSCwaSaBdVlgF+JWDJv2eoO7I+o0P8lmiAsQA3w== X-Received: by 2002:a05:6e02:e13:: with SMTP id a19mr6264786ilk.11.1631847404053; Thu, 16 Sep 2021 19:56:44 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 5/9] bsd-user: mmap prefer MAP_ANON for BSD Date: Thu, 16 Sep 2021 20:56:31 -0600 Message-Id: <20210917025635.32011-6-imp@bsdimp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210917025635.32011-1-imp@bsdimp.com> References: <20210917025635.32011-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12b; envelope-from=imp@bsdimp.com; helo=mail-il1-x12b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kevans@freebsd.org, Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1631847713923100001 Content-Type: text/plain; charset="utf-8" MAP_ANON and MAP_ANONYMOUS are identical. Prefer MAP_ANON for BSD since the file is now a confusing mix of the two. Signed-off-by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- bsd-user/mmap.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index 0acc2db712..bafbdacd31 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -284,7 +284,7 @@ static abi_ulong mmap_find_vma_aligned(abi_ulong start,= abi_ulong size, addr =3D start; wrapped =3D repeat =3D 0; prev =3D 0; - flags =3D MAP_ANONYMOUS | MAP_PRIVATE; + flags =3D MAP_ANON | MAP_PRIVATE; if (alignment !=3D 0) { flags |=3D MAP_ALIGNED(alignment); } @@ -408,7 +408,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, if (flags & MAP_FIXED) { printf("MAP_FIXED "); } - if (flags & MAP_ANONYMOUS) { + if (flags & MAP_ANON) { printf("MAP_ANON "); } if (flags & MAP_EXCL) { @@ -430,7 +430,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, } #endif =20 - if ((flags & MAP_ANONYMOUS) && fd !=3D -1) { + if ((flags & MAP_ANON) && fd !=3D -1) { errno =3D EINVAL; goto fail; } @@ -532,7 +532,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, * qemu_real_host_page_size */ p =3D mmap(g2h_untagged(start), host_len, prot, - flags | MAP_FIXED | ((fd !=3D -1) ? MAP_ANONYMOUS : 0), -= 1, 0); + flags | MAP_FIXED | ((fd !=3D -1) ? MAP_ANON : 0), -1, 0); if (p =3D=3D MAP_FAILED) goto fail; /* update start so that it points to the file position at 'offset'= */ @@ -694,8 +694,7 @@ static void mmap_reserve(abi_ulong start, abi_ulong siz= e) } if (real_start !=3D real_end) { mmap(g2h_untagged(real_start), real_end - real_start, PROT_NONE, - MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, - -1, 0); + MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0); } } =20 --=20 2.32.0 From nobody Sun Apr 28 12:32:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1631847529; cv=none; d=zohomail.com; s=zohoarc; b=APtxiXW84A23Epzay2cV1XsyVbs8LC0+r9mnZk6T6yzIH7O8LRTiCMQohdOnu5AbCv9N/xUX6EXDF2jpvEPJmRLlBe0KFf/WHlW40IiXwt5phq+yLFIzTlKOjY06DGVpCO1M77ALV19aHgaHtf00rPqd6MwbI3ZFyI8nXPE5Pdc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631847529; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YABXt7N5hYjs3+JGLkXDo6wCkHqEJQ3WPYs4NvgmbNI=; b=EBpF87qnKmfOsgJPTxRbQOZrcPq7mFdihshLYxcklsKkpU1eFqm78xIbGiuBPeanigeX1XBmvSCR1LE4jAYMpHHiLj1Z4VLJEjOfL1ktEtbvXylzL5ysE9WBERcL/Z7OYsVcE3GZHXOEVzArT5Tld95OT/Flw9/PyL9gI1Ee3jk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631847529470191.59737150488036; Thu, 16 Sep 2021 19:58:49 -0700 (PDT) Received: from localhost ([::1]:46810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mR45Q-0000tf-FO for importer@patchew.org; Thu, 16 Sep 2021 22:58:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mR43U-0006YP-Mf for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:48 -0400 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]:43821) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mR43S-0005t9-A0 for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:47 -0400 Received: by mail-io1-xd2f.google.com with SMTP id p80so3837219iod.10 for ; Thu, 16 Sep 2021 19:56:45 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id e10sm2603738ili.53.2021.09.16.19.56.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Sep 2021 19:56:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YABXt7N5hYjs3+JGLkXDo6wCkHqEJQ3WPYs4NvgmbNI=; b=mIKpaPNYlzXWx/rxCMNRLbdChNTIs+0k55uMsLSLenFeYjo/WoKZAQ6vZXoD+cpqxw NJ6OzTECxD1lE+C8QEJRaJjeucwgi8RTVoGdGJu4REFPwuHmx2jJmV4MyAYH0+IbkRLh 2EyY9pUbovRexEH3j6YchUj7eeQ/+nRlleiMIB0vb8l9GXfNB8lCRMffClf37TwyJ3U/ pHCq0sy5lw5DIGveMQcBcAAWkwrpDhlEXH8YPDjRhn5DSoEbdB4yNHRjWJuvWbvQVa1H dS3yV+POZI+kkITpDJQ3wTxRPP0GEPHEHKyGGvmFJ2d5Hl6oCmxES2fSCRRZOdm1FzJj tUzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YABXt7N5hYjs3+JGLkXDo6wCkHqEJQ3WPYs4NvgmbNI=; b=rgujNYaG4J3u5jzgyix195ZSbhI9S0JWArpS+vk4LnFt/M3Q/JgfdRaRt/e5QdIsD7 +tnQ7vOWnekCSKzCaj5iLFT58oN8DyvhC+f1x+9lRVhv9UMJ52nd5HIad53NXEjjqbY1 WSUBz/+Nsc5K9NR9KSIbppKWgiQu4Zc0LKshSWhaO91yaYXE4iU03oZBqSZQSrK8eWP7 OHzbBVT2FcQZAovded2t1fLNv4we5BRcgeccvK9PnEP/57v3MO09sLZSnc05rWrwLdnL yAz9CbKwBudkILo+aYiR/fKUsZGtIU7EBJZypomXcg5tycyatQAcqBZtq5JhzxebV+4I 41AQ== X-Gm-Message-State: AOAM530kJSvWHX7PkwDC+yte+rJSNFthg6f1vc7wrdWghwfZNqKWrK7U 6I0DnXgtqWM2YceE37XjbujTidINpIGXZE2wdUY= X-Google-Smtp-Source: ABdhPJzCv9xh8Jm0fVLYtQVc7aDPZUy6Mt9BYZkxu49kjUhUXA0mepetxdX09xaPIruXSCtqhqOTXA== X-Received: by 2002:a6b:28b:: with SMTP id 133mr6771025ioc.107.1631847404851; Thu, 16 Sep 2021 19:56:44 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 6/9] bsd-user: mmap line wrap change Date: Thu, 16 Sep 2021 20:56:32 -0600 Message-Id: <20210917025635.32011-7-imp@bsdimp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210917025635.32011-1-imp@bsdimp.com> References: <20210917025635.32011-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2f; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kevans@freebsd.org, Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1631847530312100001 Content-Type: text/plain; charset="utf-8" Keep the shifted expression on one line. It's the same number of lines and easier to read like this. Signed-off-by: Warner Losh --- bsd-user/mmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index bafbdacd31..8b763fffc3 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -399,8 +399,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, prot & PROT_WRITE ? 'w' : '-', prot & PROT_EXEC ? 'x' : '-'); if (flags & MAP_ALIGNMENT_MASK) { - printf("MAP_ALIGNED(%u) ", (flags & MAP_ALIGNMENT_MASK) - >> MAP_ALIGNMENT_SHIFT); + printf("MAP_ALIGNED(%u) ", + (flags & MAP_ALIGNMENT_MASK) >> MAP_ALIGNMENT_SHIFT); } if (flags & MAP_GUARD) { printf("MAP_GUARD "); --=20 2.32.0 From nobody Sun Apr 28 12:32:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631847712782240.12818905237305; Thu, 16 Sep 2021 20:01:52 -0700 (PDT) Received: from localhost ([::1]:54086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mR48N-0005ji-Pj for importer@patchew.org; Thu, 16 Sep 2021 23:01:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mR43U-0006Ze-TD for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:48 -0400 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]:35455) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mR43T-0005uM-Bv for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:48 -0400 Received: by mail-il1-x135.google.com with SMTP id h29so8818633ila.2 for ; Thu, 16 Sep 2021 19:56:47 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id e10sm2603738ili.53.2021.09.16.19.56.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Sep 2021 19:56:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cj37KPd2SWCobJtMrc5Dakgc5rtmPcmR/rTLXBzFkCo=; b=j4ehLSoTtYO6PEC9YeWjdNkfAr7L/OtYs8wXIEENoEETysofrtlukA7w/4dKuOXC37 1gKQtakZs/d2NCT9kSnaOy6CA+5O4FudknCVrRtQ0uFosRCF0DRUUY8qhdhrVNe5Izqd E/bwb/FeK19CqHpHG9W34gtBzS4d3ietaSFwfD5vvPM75PU5u3buWhS8uhBtlrs9NCJa 6qk6Ku0xm0TqmBXkGWpo8Swhy99L+yLyjgDV96/H/o/KayitTRnmTEFEzMVy+67vvhKo wwIgdRiT9a5cPnUKiJRMlgk27b8q6tXM5XAeVD/rPs+ZGJSXjO5O2jxLATU7xihSNo5t QX6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cj37KPd2SWCobJtMrc5Dakgc5rtmPcmR/rTLXBzFkCo=; b=H0RMIIEHPzZEKIyrTiphJ0oXINiA1xNXrE8jUxUP/vtXR2MgodDAcVuB8z//+0giy3 nVOlDVN9i93aUUbD8BTuYW5B+kGbClmIFIXiJ92J7eSfVxp8BIChuWCl4GgaaNCcqvFO Hrkb8kM8W9E6rnYoyNU9vQeB8/XWZwyst4azh4NkmKFyCtCR+LXxYP6ehKBjNXRXgbEY w+DBtB1b1Ler3QED4xuYGylx8UqxIL2Nu5b+vDNdiJ7bWT7n08ic7OD3U+Jxiw+G5aK9 3VcbNXpwWJyIKmFJRKZiIk7Zo0ZfJhxUW48pPG4bgRbIXKvxeb2yp5J6+qtLOJBFdeFv UL9w== X-Gm-Message-State: AOAM531vva9vIWSIe1t4A+xN7+O+pLLcI23BmDpuIJNKAgiPjCIiLQwp NWmkR8wyk3LBau0CYLqqitIZTR7C0UtyCEuyjqI= X-Google-Smtp-Source: ABdhPJz7UfCuZ+20rzNfSMufS3B1xV8dmh8toTCd1tTWL4mqcx+MreQnaGqzRWrUXRMVivH4fcvcHA== X-Received: by 2002:a92:c145:: with SMTP id b5mr6036399ilh.203.1631847405980; Thu, 16 Sep 2021 19:56:45 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 7/9] bsd-user: Don't try to mmap fd when it is -1 independently from MAP_ANONYMOUS flag Date: Thu, 16 Sep 2021 20:56:33 -0600 Message-Id: <20210917025635.32011-8-imp@bsdimp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210917025635.32011-1-imp@bsdimp.com> References: <20210917025635.32011-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::135; envelope-from=imp@bsdimp.com; helo=mail-il1-x135.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kevans@freebsd.org, Guy Yur , Warner Losh , Guy Yur Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631847713999100003 Content-Type: text/plain; charset="utf-8" From: Guy Yur Switch checks for !(flags & MAP_ANONYMOUS) with checks for fd !=3D -1. MAP_STACK and MAP_GUARD also force fd =3D=3D -1 and they don't require mapping the fd either. Signed-off-by: Guy Yur [ partially merged before, finishing the job and documenting origin] Signed-off-by: Warner Losh --- bsd-user/mmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index 8b763fffc3..347d314aa9 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -154,7 +154,7 @@ static int mmap_frag(abi_ulong real_start, if (prot1 =3D=3D 0) { /* no page was there, so we allocate one */ void *p =3D mmap(host_start, qemu_host_page_size, prot, - flags | MAP_ANON, -1, 0); + flags | ((fd !=3D -1) ? MAP_ANON : 0), -1, 0); if (p =3D=3D MAP_FAILED) return -1; prot1 =3D prot; @@ -162,7 +162,7 @@ static int mmap_frag(abi_ulong real_start, prot1 &=3D PAGE_BITS; =20 prot_new =3D prot | prot1; - if (!(flags & MAP_ANON)) { + if (fd !=3D -1) { /* msync() won't work here, so we return an error if write is possible while it is a shared mapping */ if ((flags & TARGET_BSD_MAP_FLAGMASK) =3D=3D MAP_SHARED && @@ -571,7 +571,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, * worst case: we cannot map the file because the offset is not * aligned, so we read it */ - if (!(flags & MAP_ANON) && + if (fd !=3D -1 && (offset & ~qemu_host_page_mask) !=3D (start & ~qemu_host_page_= mask)) { /* * msync() won't work here, so we return an error if write is --=20 2.32.0 From nobody Sun Apr 28 12:32:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631847815753359.35925411158576; Thu, 16 Sep 2021 20:03:35 -0700 (PDT) Received: from localhost ([::1]:60670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mR4A2-0001lY-NW for importer@patchew.org; Thu, 16 Sep 2021 23:03:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mR43W-0006fK-IY for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:50 -0400 Received: from mail-il1-x12e.google.com ([2607:f8b0:4864:20::12e]:44939) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mR43V-0005v7-1S for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:50 -0400 Received: by mail-il1-x12e.google.com with SMTP id x2so8734683ila.11 for ; Thu, 16 Sep 2021 19:56:47 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id e10sm2603738ili.53.2021.09.16.19.56.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Sep 2021 19:56:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZO8JmiDexvxr2bkytagXw9QqKDBdH9/0PrYHGp52LZE=; b=RCCfAVHLJsJpXqgNwHIREwEQYb+npyd1Vn7JlBXpLe0o2VyffXVQ2CfH/jveEQfyzL foi0ApUr3ZDHwXlnJ6HemOueY/kIkzeido8KQluXdnFUEWmnAGEqiwM4Pgu8/if1scDw In0L7klP7Lqe9oAORfilQPd+iFvXxWavj6HUztmQh1ABJWKwBiAdwRolYjkjqeqDFYFI 0VII9l7EaJj4R2ucID4CzlNvwkYAoooGk4xdxcFLsJXEJAx7Fg7aILirdlkoQyOldJMq uENaYPqNKzKh9+yp2Gidz6SGFYa5LDNpnRZPOyLjTnHVhmz+sKWlcF9CK8kKZj4VnWsD 95Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZO8JmiDexvxr2bkytagXw9QqKDBdH9/0PrYHGp52LZE=; b=bu4apsnS48qw1yndWStSR7jEx70s0qGq2dHX/EuefgFbL7wEE9Qr6ttY4B3AVwWKq+ wnPY2HTY3CIQMm3MIpMk9QTMZ6GgYFRDt1Iu/O1wC2IZkAdFugDhcOt09JxkF0sjEPVp 1vMUrc5yvjpiOrC8+O1wAkIExK5EsZrIULiblQoEjehuTXqbuwV962zUfqWbaW5hI7tW EWJCWVRYHvczIobaPaq+23VYwMy634gZIZexDljkybWWCBmL4oU6v4ZsbKd/hi/5v8L5 pJY7jyuscnNjw6AxHz9eekeoiWov+Rye5uGqmtO9EqhAtK8yW/XCFBOGn4BoQi68Op5t scfA== X-Gm-Message-State: AOAM5313j8kbj7ts8lHMyT8woT4RKwphgK1FZVMqxdG59vCf1vT9IgGH x8s3WgYs+pThQ/ordq4o+XItJ/Dk3iRYq92uyhY= X-Google-Smtp-Source: ABdhPJyDiJx1JyIarVAH75qhEMyznNCpMD+jWkPsIPEwiSb9riNW+XACN72yDLTXA9NrikBbXx5Jow== X-Received: by 2002:a92:da85:: with SMTP id u5mr6471621iln.213.1631847406784; Thu, 16 Sep 2021 19:56:46 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 8/9] bsd-user: Implement MAP_EXCL, required by jemalloc in head Date: Thu, 16 Sep 2021 20:56:34 -0600 Message-Id: <20210917025635.32011-9-imp@bsdimp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210917025635.32011-1-imp@bsdimp.com> References: <20210917025635.32011-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12e; envelope-from=imp@bsdimp.com; helo=mail-il1-x12e.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kyle Evans , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631847817043100002 Content-Type: text/plain; charset="utf-8" From: Kyle Evans jemalloc requires a working MAP_EXCL. Emulate it by ensuring we don't double map anything. Signed-off-by: Kyle Evans Signed-off-by: Warner Losh --- bsd-user/mmap.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index 347d314aa9..792ff00548 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -387,7 +387,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, int flags, int fd, off_t offset) { - abi_ulong ret, end, real_start, real_end, retaddr, host_offset, host_l= en; + abi_ulong addr, ret, end, real_start, real_end, retaddr, host_offset, = host_len; =20 mmap_lock(); #ifdef DEBUG_MMAP @@ -599,6 +599,14 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, i= nt prot, goto the_end; } =20 + /* Reject the mapping if any page within the range is mapped */ + if (flags & MAP_EXCL) { + for (addr =3D start; addr < end; addr++) { + if (page_get_flags(addr) !=3D 0) + goto fail; + } + } + /* handle the start of the mapping */ if (start > real_start) { if (real_end =3D=3D real_start + qemu_host_page_size) { --=20 2.32.0 From nobody Sun Apr 28 12:32:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163184781478943.25560148056263; Thu, 16 Sep 2021 20:03:34 -0700 (PDT) Received: from localhost ([::1]:60606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mR4A1-0001iy-Oe for importer@patchew.org; Thu, 16 Sep 2021 23:03:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mR43W-0006fA-HY for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:50 -0400 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]:44858) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mR43V-0005vY-1g for qemu-devel@nongnu.org; Thu, 16 Sep 2021 22:56:50 -0400 Received: by mail-io1-xd32.google.com with SMTP id g9so10411698ioq.11 for ; Thu, 16 Sep 2021 19:56:48 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id e10sm2603738ili.53.2021.09.16.19.56.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Sep 2021 19:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X+vTeyxw0Y7XMbUlb9ar4nVtg7R/vO/Nf/AXyGz84LM=; b=tBZMyBYr/NCclqQ3apNIjCpNcSa+LT3jcN91rYDLEHLYnsCGJNNuQ3Z3NBWTCF3pFS LJqW4fQmdoT3NvzmKg4A3Guhi0wrZVKCWJsux/VEL6hP4vZu4CO+y0oyAy99XB1DfAZ2 JfKHfjkvV+JUFMIotxh7qOrUY1Qqho6Hzv5oCOuukOie6OSehT67D6IQPnt5NoKX3G46 +5+M/K1RNfCT/ljUf5WXxD/eWgSl+P6jbsgJVEaT/DtfFds6GPbu0knSCWHtPRWPMtyG y3VZSvE9mQjP6UllI3bn6jbE87lKd3xGPnMACCSTI4eVTALl7SPBQjRmb84BkrNqOpjO 0irA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X+vTeyxw0Y7XMbUlb9ar4nVtg7R/vO/Nf/AXyGz84LM=; b=IBs2wu/o5S1uFvszhD5FOi+ZebRGxiSPRgcN5ChWuGczacYBl+XkmjdeRgz/rvAaqi VW8pqCUFtfv1SMQaz6EqFvYoLKUK96BGSh/GrDQHm1yH6ghAO+RGSXbJdiwwH8BFCNvg cAaBQAwhTPNIttxjeZM7F1XJbD/6meJCHrSpkO6uBUc6kleDRrO6F2Snu0Vg50LGWhfV asynaOnuoiNhQDj3ISoTcXFTs7MTo0+z/GPsOWS77nEYZ6XejN2SJvCiGbwLfuiBIioV 2Vxl49N2kGuwii/4nLMrkeXZv3ZSXox2mmfcdXBUANFFnvah/cvcPadwAm+Kf1skc+R4 g1ZA== X-Gm-Message-State: AOAM531D3j88eUcRU47YfFxHF/y2yP90pQcEYeF23v/T+2I/bfhq5Fe6 vcP5yBxRp9C4dCzYpffW5Hd9ZTbFmZj8sLizccw= X-Google-Smtp-Source: ABdhPJzrUYUGyRn68LISycxfq8tdJPy8yiwr0XkToHWS/jyN9FOSLYVgmHHY5YPCed5L+zX2q5hrSg== X-Received: by 2002:a5d:9355:: with SMTP id i21mr7014142ioo.12.1631847407557; Thu, 16 Sep 2021 19:56:47 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 9/9] bsd-user: Apply 86abac06c14 from linux-user (target_mprotect can't fail) Date: Thu, 16 Sep 2021 20:56:35 -0600 Message-Id: <20210917025635.32011-10-imp@bsdimp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210917025635.32011-1-imp@bsdimp.com> References: <20210917025635.32011-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d32; envelope-from=imp@bsdimp.com; helo=mail-io1-xd32.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kevans@freebsd.org, Riku Voipio , Warner Losh , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631847817045100003 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini linux-user: assert that target_mprotect cannot fail All error conditions that target_mprotect checks are also checked by target_mmap. EACCESS cannot happen because we are just removing PROT_WRITE. ENOMEM should not happen because we are modifying a whole VMA (and we have bigger problems anyway if it happens). Fixes a Coverity false positive, where Coverity complains about target_mprotect's return value being passed to tb_invalidate_phys_range. Signed-off-by: Paolo Bonzini Signed-off-by: Riku Voipio Signed-off-by: Warner Losh --- bsd-user/mmap.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index 792ff00548..4ddbd50b62 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -591,10 +591,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, i= nt prot, goto fail; if (!(prot & PROT_WRITE)) { ret =3D target_mprotect(start, len, prot); - if (ret !=3D 0) { - start =3D ret; - goto the_end; - } + assert(ret =3D=3D 0); } goto the_end; } --=20 2.32.0