From nobody Sun Nov 24 11:59:45 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=1722643180; cv=none; d=zohomail.com; s=zohoarc; b=eEQMz+duqx/q5ISS6rPmA064Dm0X80EqaB294WAOqqWNBbTWfxgZMtxPy01ieDfeiF/xyaGVluk6Ei2hKC5FWj2ecOFP7wWhQK4q4AJjarIzsMyoT1JeOiigB2ayTz0p77Wq6aTZ5GD4PLLSOS2rbgehDK+5oC0YKRmWkmz4qSw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643180; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=P0Hc+tmyI2fNQswWMe99iI3Cy9S9k8Dxg+dtGkJKvsc=; b=VFlmXCf+WW2ImP/7jCZOieeSLuGGgTXAQDIY2wBgd93zKMkkMFYvGGCJ7upwp46IlH9g24GkmLBgt8uTe/1P0ZHJGMmDbIvYcfk5lvq9bbaVaEEqolCglHgvwvXRl6Xs9p1eZXvCLMDeWXf8dQ6gG7iTMKRNnBbSEecSBbn1w2I= 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 1722643180003874.2243608861943; Fri, 2 Aug 2024 16:59:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29b-0001Vw-7x; Fri, 02 Aug 2024 19:57: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 1sa29X-0001Rg-Fh for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:43 -0400 Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29V-000458-M0 for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:43 -0400 Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-81fe38c7255so3103039f.1 for ; Fri, 02 Aug 2024 16:57:41 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643060; x=1723247860; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P0Hc+tmyI2fNQswWMe99iI3Cy9S9k8Dxg+dtGkJKvsc=; b=Rb2vXvFkt2mn3vLamOLDFSAXUsegdlikrSXYsrxSsnUWr8bztrpbRQsnGzpcjR6LcE W1HcgiRJLO6qZQjUW8HkxIks0gBAyaMzYvC4VwC50sZ0hCfrvIu9fMEMvAtGnNoNYrGe dmCF6D0v7K2gvK9ZdL9WKNqkL87hyD38vvpPCj8IGXzi4vcwilyLVd9oh68m9BQVyopO ezgblLKAygVgO3KWrgPYRoKOXZC6JcadukREcDcuFJqwNvrdgxIuwjMBWeWeiF8xkhYG D8qHG3vmRAvYYo3e6DM9MiTEUHL4mAE3AWThO+CS6hvxwmHYgDB+6DFaNhXuocechY/k vc7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643060; x=1723247860; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P0Hc+tmyI2fNQswWMe99iI3Cy9S9k8Dxg+dtGkJKvsc=; b=XXs7CsIiQGhiAy/xrX9kE2C1tASFmhZa71mDCzkcocvHUGhuVQONJ1XwF4LZtHgq4H wP1BZfy9tZRVaXGd4/PXq94IUKNnudt7dcXq9Ey/5uleirDC2Gx95SsYHznwm8zyIN/R eayCYCVjE8LHWH3LHpc0Heka3ksKLRl5JDcUJwIv0OVdE697UzNKq+gPYSVVg/zaueQJ v5GkFj9xJFeqbJlVOngLb/0BsmiOTbtdPrFB+l5Wt0z1rxc9MVzlUcl5Ar+O6q91XxP3 qLYcTC1xMGCSPfBSx4uoAPNRRmPdHhsLPQ9DE1FP4SpcaTkUzFPgsyazN0K9GcKmH/n/ ZgVQ== X-Gm-Message-State: AOJu0YzIKZNvul4aF8Gn3sPskNL1Rc10KBXx3LdrRrmMZ3QtQKagyjps LsLWWob90GNNnELb+sdnbwQN/WNYrpNviGVnxAxHYXMKYSh/uH5+YFf7FlvSJYXJJWw16lRALhq Ofr0= X-Google-Smtp-Source: AGHT+IHNPRICCGvgkgl8kGlCYZIWMu3VHcnnPJ540hiqUAA7KZyeQ/9qom0J8Sdm/SbB7oOnJGI9Lw== X-Received: by 2002:a05:6602:1509:b0:7f6:8636:f89d with SMTP id ca18e2360f4ac-81fd4348a4dmr649254039f.3.1722643059875; Fri, 02 Aug 2024 16:57:39 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke Subject: [PATCH 01/17] bsd-user: Delete TaskState next member Date: Fri, 2 Aug 2024 17:56:01 -0600 Message-ID: <20240802235617.7971-2-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-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::d36; envelope-from=imp@bsdimp.com; helo=mail-io1-xd36.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643181071116600 Content-Type: text/plain; charset="utf-8" The next struct member of TaskState is unused. Remove it. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/qemu.h | 1 - 1 file changed, 1 deletion(-) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 3736c417860..4ccbee265a1 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -83,7 +83,6 @@ struct emulated_sigtable { struct TaskState { pid_t ts_tid; /* tid (or pid) of this task */ =20 - struct TaskState *next; struct bsd_binprm *bprm; struct image_info *info; =20 --=20 2.45.1 From nobody Sun Nov 24 11:59:45 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=1722643157; cv=none; d=zohomail.com; s=zohoarc; b=SbFydTUU2DmRpQihMGr/0no/d3MKrE7fWF52uZZ5T/8PeXSxWOxyZDnBe2w94yWLyPA1ae1WzqqIrCFQfl00mu8kFqqWVonS/Wq1JIYCnSAzUsCI/cMgZp2C+60UmIeUVghsG0E6Ocm0AqgvukjJyUDfWwe2s05wyNc4hEu0Q6A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643157; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pyqu+sSEKz2WONWccyrlSdXXuq+wJEyOvfRZMJHkZxE=; b=Z54SCi0O09JH4XEu6a5eYxlAA1rbvOw3gi39igJpG5OElHRXrEllvi/SUx11Qjt8jSKUNFXj8MkU906WDF6NmHcmQ3M5md6Vl0Pi4eeYmTAE8v7RawK0SAdoXtxdcY5M+1saI7K33iuGayRhB7a7anas3r2k8pmkXAEhlfymrUs= 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 1722643157376678.8083351683405; Fri, 2 Aug 2024 16:59:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29h-0001jt-3H; Fri, 02 Aug 2024 19:57:53 -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 1sa29Z-0001TG-Bw for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:46 -0400 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29W-00048l-IF for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:44 -0400 Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-81f905eb19cso432310239f.3 for ; Fri, 02 Aug 2024 16:57:42 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643061; x=1723247861; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pyqu+sSEKz2WONWccyrlSdXXuq+wJEyOvfRZMJHkZxE=; b=QJu96iQc6MS66pOpp06vULg2O+4v4aavlqnrNuzgg235M9cW9MR7KwvYy5xyPjVm/k zxU4Yw0ExfWwvBQFr6o5KCb7o+2zIZ2PFXmoQm/X/Q+P1J112gVy11WaqurGZUBvfnHq VgwOXbj/jYNs+3IjcDS19evwrclKLCVn5/S6m2CApPlGD7dBmq8cZoX09mKiStzajZLK gqLkHniTyVlNNfmAI/Xf8BoicN0srBA/8ZWxeWnyA36WLi5C1Oc03nBE2KkMiXq2F0aq AxRdHJIyfpPGkvj6896uUW1foUXqeG6h5kB8UNqjqq727/XUGST0CbLKU75H1jLv7Fkm Pb6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643061; x=1723247861; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pyqu+sSEKz2WONWccyrlSdXXuq+wJEyOvfRZMJHkZxE=; b=N68G6VblazzvqoW8w4eclVLAmRk7NBbGF4wnBlVuIuEU5Qh2sq/JyGVyanJWiNKTVR InTIhUzerMDBHkeC1OYmb5bAl7hboCjpf+3EI4oSmPpYfdK+9zbAurs7Pg4z1uOtozoI +f4VhL6p7vVjZZYDbolSFgsdJ/X1bZf+2wzjIJmVIMDHm06n5A00XQ+8sJ8KfRTJ9n95 Qqmn6hWYRErLEfSi1j03h4/MKyClKGhyZDKDaqqzyW8oChKTDCqi2jn+rD8DGMjqQEIr ddvMiEa7UptbE10e86nIxxqQFgt3tjIb7DCrhT+RsGLBfo4jYvl3VK1MarWe5q4vKZ8g 2Seg== X-Gm-Message-State: AOJu0YwRH12PVQ+/xLUb9vXTj5FIxVdnNf93SYQjXNER96oHWeDDGB+9 hxAjoWL8euAuWpN205IPn+4dN6u7FM+RJ3UQ6VMzqqt8yj5POjPdhV9RMnhCIuNrq5G0sBIIpsL HJcY= X-Google-Smtp-Source: AGHT+IHHhNhfLXIek+dc/cEjJNjaZTHitp9FJAU3pzJdGWBjv3VxjdTjw7vSZsH4uEp7wR9FW/hdXg== X-Received: by 2002:a05:6602:6c07:b0:81f:922d:b3b9 with SMTP id ca18e2360f4ac-81fd4399516mr761525539f.14.1722643060897; Fri, 02 Aug 2024 16:57:40 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke Subject: [PATCH 02/17] bsd-user: Make init_task_state global Date: Fri, 2 Aug 2024 17:56:02 -0600 Message-ID: <20240802235617.7971-3-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-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::d30; envelope-from=imp@bsdimp.com; helo=mail-io1-xd30.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643159207116600 Content-Type: text/plain; charset="utf-8" Restore init_task_state to its global status. It's needed for threading support outside of main. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/main.c | 2 +- bsd-user/qemu.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index cc980e6f401..4d29e13a8f5 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -213,7 +213,7 @@ void qemu_cpu_kick(CPUState *cpu) } =20 /* Assumes contents are already zeroed. */ -static void init_task_state(TaskState *ts) +void init_task_state(TaskState *ts) { ts->sigaltstack_used =3D (struct target_sigaltstack) { .ss_sp =3D 0, diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 4ccbee265a1..c7f78096734 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -119,6 +119,7 @@ struct TaskState { struct target_sigaltstack sigaltstack_used; } __attribute__((aligned(16))); =20 +void init_task_state(TaskState *ts); void stop_all_tasks(void); extern const char *interp_prefix; extern const char *qemu_uname_release; --=20 2.45.1 From nobody Sun Nov 24 11:59:45 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=1722643155; cv=none; d=zohomail.com; s=zohoarc; b=ZBeunPVSYadzIFlJRtsiVxiO16sxKKTVx4oE+z0QrMRc6mXbMPwHbMV9lxnVqLvNmLOI2SvFTf6TYx99zm9jfRAqyFp8pLHJ9TW/EfTz5ZOkyBebenj9XxPAkRKPuGMZ97bvdpjWspxbvkk3/l+ue00Sw3gPF0TbSs+h8zwSfZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643155; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+YbJS1lujiJw+GBrT/gz6au1tdNTic+L9ACEewZENu4=; b=OpHphjOxpg1LLmHd1lPIxil9fPJsiFYWOB1fN6XZ8j3/xrlsU2BsAXEfvWc05yE6VUK+guvxRXWNxB8GAsKsiIoCHSmmAwjqcGVp/MDRr96GvyLtADxDAUCM7zUm2UZRSddm56SKobP0U4eapLRGUfeeOOLakNJFgXKIbB1z/MM= 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 1722643155580749.4027766964125; Fri, 2 Aug 2024 16:59:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29k-0001yZ-2r; Fri, 02 Aug 2024 19:57:56 -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 1sa29Z-0001TH-C9 for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:46 -0400 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29X-0004As-Kg for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:44 -0400 Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-81fb80d3887so213703239f.2 for ; Fri, 02 Aug 2024 16:57:43 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643062; x=1723247862; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+YbJS1lujiJw+GBrT/gz6au1tdNTic+L9ACEewZENu4=; b=d9YXHKVkSCtdHQkUyV2Hr9rL3OtKk1HuDE8d+vRiRlSI7iN9Z7A3vUPcZRt6iOGMzF VGCNxpgTR3wTPJVQ3z89CZ0Ue4q5e7s1ww0ZVoG7Wp+qR/4A8C53gl5esuDO2sCxxb3s fYc8NbdS5yoNncYwcKVod+RIqUil2R0J9clO5/ZfPn+3bQ0g9H8QqSi5k+fhtlunMSib 1m1TbTWVTJejwdj3Hw7NU++FbhRELMJo+HfD5NNFu6AkBPH+Nz22lUviiXw3q6SSOHwr RSkyVpLpFlRTpMpUsJeIsKcF/oGT9diMfzZ1tw0eYFVO84sCcF13AOfEd/7zBdQbe5rH EEiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643062; x=1723247862; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+YbJS1lujiJw+GBrT/gz6au1tdNTic+L9ACEewZENu4=; b=l8rjwFSEM+GoLFG/+Ak7RT7FFuBGV6UM7w+VHETbsYcxQbHxYqdQ3wfazpydVDfDgO uzzpzrq7bcBoC6++jKX70dtwA5V34g1AQKG/EI51S77epmDESXXmDY0MBZ8U401cciOJ 7F7XQBaV15/8Br/t/V9yqIZGkpLtZZOUiVzdkgV01pQ0cYNAJG3gqqua/Mx7wpGeKvJ1 t6E8YJg9bzvEWV06n2w96PRZ1AGdoFvwDDhvOgiIFRRMeMWSthW6hZhI/2UPEMjTmXpG 8BbAPPs8vWinf0yCc99m3hBPxML+clxxmCYJ7UVjE0adNDxz22LQ879DjRN1Mfh21DvV 936g== X-Gm-Message-State: AOJu0YymtCl5QWxvvFF7BpZIlxY3tiSsUNIA50FCJPtLwV+QmELgwuWK 7O/j2kR8Ph9VTnihep2Zy0lHPupCBBL7WOTtyd1gYP8dSGavWoqRDwmDpVf+WIIrsS9lfe9ku5j Zsps= X-Google-Smtp-Source: AGHT+IHkmOSmtZ3pI8aGjUdQpwWcYxsDJX+nfQRwPEykWpmePdwc9GGimkCC7JuU1e4iMrHmpvP+Tw== X-Received: by 2002:a05:6602:2b8c:b0:7f9:6afc:182 with SMTP id ca18e2360f4ac-81fd437a289mr747985339f.9.1722643062138; Fri, 02 Aug 2024 16:57:42 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke Subject: [PATCH 03/17] bsd-user: Make cpu_model and cpu_type file scope Date: Fri, 2 Aug 2024 17:56:03 -0600 Message-ID: <20240802235617.7971-4-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-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::d34; envelope-from=imp@bsdimp.com; helo=mail-io1-xd34.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643157256116601 Content-Type: text/plain; charset="utf-8" linux-user already does this since 2278b93941d4. That same commit just added them with main() scope to bsd-user. We need the cpu_type, like linux-user does, to create new CPUs outside of main to support threading. Move both cpu_model and cpu_type to mirror linux-user/main.c. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 4d29e13a8f5..1533fd51168 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -62,6 +62,8 @@ intptr_t qemu_host_page_mask; static bool opt_one_insn_per_tb; uintptr_t guest_base; bool have_guest_base; +static const char *cpu_model; +static const char *cpu_type; /* * When running 32-on-64 we should make sure we can fit all of the possible * guest address space into a contiguous chunk of virtual host memory. @@ -251,8 +253,6 @@ adjust_ssize(void) int main(int argc, char **argv) { const char *filename; - const char *cpu_model; - const char *cpu_type; const char *log_file =3D NULL; const char *log_mask =3D NULL; const char *seed_optarg =3D NULL; --=20 2.45.1 From nobody Sun Nov 24 11:59:45 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=1722643131; cv=none; d=zohomail.com; s=zohoarc; b=c/LQZEKTElb2yVpWKQWQTBR26bSAmO9NkVzsBO6u0hHHbNjL5XbYkPDeZJVQpaHSIWMx9Aa5TCDpAkMvrnrEi8uKUApZoz+pKiC2bSe/dao/X6HdyaagKlQI7sQNHlWAYHlqvSpXq/mdWhIbqP5Ce3asYnxLpBGMCqoEP+RaxVI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643131; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=i+M2MfyOC3APTOH0qT5489YkK6Lsz6CNB5NL1MMUEoY=; b=bCivGxx/hVoValqrc1ijCS/n3rH4qPGUsmkBvXmkb3LZ65YGeTcX4HmghAM+iNgbq6BZu7fruCyktRuXWtOFsJ4+EGH+JEl0I5uuFQ0LtfzATUL/UN1H1XrgDmMwMhmEg54MDdZ4H0rBdI5sesqWRuxhf9wM7WpR3ejHmzdaYz4= 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 1722643131900563.0044023671625; Fri, 2 Aug 2024 16:58:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29j-0001wG-FW; Fri, 02 Aug 2024 19:57:55 -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 1sa29a-0001Tl-LV for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:46 -0400 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29Z-0004EO-5H for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:46 -0400 Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-8152f0c63c1so310173339f.1 for ; Fri, 02 Aug 2024 16:57:44 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643063; x=1723247863; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i+M2MfyOC3APTOH0qT5489YkK6Lsz6CNB5NL1MMUEoY=; b=C/aJSUEOjiak6/wTjfAkly0xjzXO1HfzVJK6xhYJnAXxZtHpRALUAllEUO98BsvjD+ 3x5+1rzPvZgC22dhCxY/jUjr0KQlCCnzDt37ZzDrUkbLJ2+B05UlA7KtsnR3CUtUe0L9 f1KXrNnTjYKyTbzSd5Nj0ch4fC23ZfmOiP0+tVSo5p6ZpT613MhK5mRgiEbMcbWZvFZl rE9k5FtA//xFP+bc9gGvGXzeMysCdy60nuQwsNXL1cAR/BLF+Qg+OR0CT3IZBO9UOe7v AD5ArL3thBoQ/GF8iBlascgqNozVKvpxMMlGIiTjVKctkupWolNEMqFGKoVhicGtiZxA EVxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643063; x=1723247863; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i+M2MfyOC3APTOH0qT5489YkK6Lsz6CNB5NL1MMUEoY=; b=TYdfH7Dep0Kh6DyTlr0TL6yBUWdfkPuPhkuKqcKRFgVK3V0bQIbol1IDH7o+qZhJPL OziT6Oy5lUjeNEP2hAwbfHbpgKN7+y2TIvFXd60yncRLCEWoulDFsuP/fXmfUIu1CfwT xkzmq4IgCt/zhd6S4bo84rt17OLHVWgMoensbkt+AuKht1xDGacnmLBnG9X0Aj4gzrVp D7uX49EAuCR0UTKHvTtKlAuFJ45BOB06iMp1M3qji79PSa0y9thnIMSoGYJXQ0ZT2NJO XW3HwF0vsKzxRk4bZTkxGVQz3gglQu04nnRcqB0yB1ebd5Kj42pWUk38yrwu3ApY4s1k nxBQ== X-Gm-Message-State: AOJu0YwcWgZxbXOSSmdqjyj14GfroobUu0y0yWnHKtHG9SpESizca04m NWpP3ExdawhXp/F0c9kpdOc6yyyTRzsRHtatRIvQ1bVyFzrYKf8okn4Qs7yW0Ce8sDvCb36pBVu EbOo= X-Google-Smtp-Source: AGHT+IGppSYYqBA7hedKkDI4HBy9gNIJuSyRuommAOrM1q9arH0ioYRQOjbSk/3u+KaDK4EMElyGNQ== X-Received: by 2002:a05:6602:2cc8:b0:81f:9826:19ff with SMTP id ca18e2360f4ac-81fd4374a3dmr708269339f.9.1722643063174; Fri, 02 Aug 2024 16:57:43 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke , Stacey Son , Justin Hibbits Subject: [PATCH 04/17] bsd-user: Implement cpu_copy() Date: Fri, 2 Aug 2024 17:56:04 -0600 Message-ID: <20240802235617.7971-5-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-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::d29; envelope-from=imp@bsdimp.com; helo=mail-io1-xd29.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643132912116600 Content-Type: text/plain; charset="utf-8" From: Stacey Son Catch up with 30ba0ee52d15 and implement cpu_copy(). It's needed for threading. Stacey's original code, with bug fixes from Jessica, Justin and myself. Signed-off-by: Stacey Son Signed-off-by: Jessica Clarke Signed-off-by: Justin Hibbits Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/main.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/bsd-user/main.c b/bsd-user/main.c index 1533fd51168..9ad31bd1efe 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -224,6 +224,37 @@ void init_task_state(TaskState *ts) }; } =20 +CPUArchState *cpu_copy(CPUArchState *env) +{ + CPUState *cpu =3D env_cpu(env); + CPUState *new_cpu =3D cpu_create(cpu_type); + CPUArchState *new_env =3D cpu_env(new_cpu); + CPUBreakpoint *bp; + CPUWatchpoint *wp; + + /* Reset non arch specific state */ + cpu_reset(new_cpu); + + new_cpu->tcg_cflags =3D cpu->tcg_cflags; + memcpy(new_env, env, sizeof(CPUArchState)); + + /* + * Clone all break/watchpoints. + * Note: Once we support ptrace with hw-debug register access, make su= re + * BP_CPU break/watchpoints are handled correctly on clone. + */ + QTAILQ_INIT(&cpu->breakpoints); + QTAILQ_INIT(&cpu->watchpoints); + QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) { + cpu_breakpoint_insert(new_cpu, bp->pc, bp->flags, NULL); + } + QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { + cpu_watchpoint_insert(new_cpu, wp->vaddr, wp->len, wp->flags, NULL= ); + } + + return new_env; +} + void gemu_log(const char *fmt, ...) { va_list ap; --=20 2.45.1 From nobody Sun Nov 24 11:59:45 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=1722643155; cv=none; d=zohomail.com; s=zohoarc; b=da9qqaNAJa+M5MK1Ti0OC7YOoPkZ3audO5QO7gbaHG4LjfmsXwExdECgFdcSkruWUKvOCac3rCzIQ+AOy+3zIvVQerv3gFWw1fLJVr8NpKKFKoczMp3VCSon3lJQ2/n+8X3c/Owniy57wyaD+Ww8ujat5MIzDrnPHTQD8ccbrL0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643155; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TT3QX4LoQAijDXK3PbVvKtS6ffPFG//HKfS5znuzPiU=; b=JgSe+sGy5a06BTZpuO4lBFIS0l51oTkcWPjXKPmCdkWzB7MvS7KyVn02P5IDEbclQvjjem09YZqN283OhEgSc7rU3p8Pg2YTFLnfSoRa+vJEQNjB6cpf8JXb/ZVcc4/lHxfK1DNopbNDMw0865Io/SLVITYykM4WixC4IT6NIxU= 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 1722643155628703.1389264604665; Fri, 2 Aug 2024 16:59:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29k-0001zw-Eb; Fri, 02 Aug 2024 19:57:56 -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 1sa29b-0001WH-AC for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:49 -0400 Received: from mail-io1-xd2a.google.com ([2607:f8b0:4864:20::d2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29Z-0004HH-SG for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:47 -0400 Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-81f8f0198beso363088839f.1 for ; Fri, 02 Aug 2024 16:57:45 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643064; x=1723247864; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TT3QX4LoQAijDXK3PbVvKtS6ffPFG//HKfS5znuzPiU=; b=oP1rAz2pyeJN3GyKijg27cI0TsnUlEDG3yQdLGDiBVReu/9vWoJzmbYUlB3zkVT5TA xIXcf8TIjLlsy62w13dTV6odmQS0+aU+8LKfyPFo+wmUfNCxAiOEiSiQqC+IZpulWRGq CCvXZHGws8xLfvCWHLH7c6RxMvpgrjKG8IiJRGD2zuhaA7JI/NfujFkLAnK5TL01sEYN F0mSydlrmTVzuttTI/GXgmRkFRXNoMZz1gXNo8AasVixJtrOpw17LSxOvqB+juTDoGP3 RlbiIhahYM0fScNQQ1nyyJSDbPyxq1Umpk5cTA68RgK+n4LiuDKSE8gWj/Jp+ODLnHEk VLiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643064; x=1723247864; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TT3QX4LoQAijDXK3PbVvKtS6ffPFG//HKfS5znuzPiU=; b=efjWFIXvHRRbTj+ZQALkolmZqWyApv6MzEo+ZPWUQf0jhXoOCQl4jUNi/Eo3vYek5o aOFB8zcsXEX1YolYlyjABRbmuk/mj9x8kFsz7B36+S0z2VlTbnPoPXd/pA2ebx7MZP5c d2aI0DgfrUyuHu9ttyZft5eLtxJzyetQ6WQTyOB7XS+JHCcsqel78i7SIilFL4o2g3x9 pO6jEuPlW9y97IEr/MzZR893ar6GxzP0mysJhvWrYJVDSef8xQXE7U4kcoIIqNcsG+Bt UyZH5ydG4zbaSNoUrs9F9YeilAQ1Ee+jzqw+jjz3Fr8g0LEOgtWhjo0uRKyyCYZVwDlE IPbA== X-Gm-Message-State: AOJu0Yw5a5jzr2UHg9dGaamXqByRRojT5+yz0Vsh9K7nnMGb3uEELxbG 81qObrSY2y/wIijCEKN+rk6p4YcKbFZtIE/JGvAF/r7kJyA5HKWpRA9u6bhSXn4YuDCOBTRh9GU inmo= X-Google-Smtp-Source: AGHT+IHKMQy2uGTBXZNGdTpzn44FwHdb5451ftzXLqW17nSXCtUxbEnaKZOHbwwYB8Bmw02RhowFvg== X-Received: by 2002:a05:6602:27c4:b0:81f:9552:e091 with SMTP id ca18e2360f4ac-81fd43623f5mr567102039f.7.1722643064423; Fri, 02 Aug 2024 16:57:44 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke Subject: [PATCH 05/17] bsd-user: Eliminate unused regs arg in load_elf_binary Date: Fri, 2 Aug 2024 17:56:05 -0600 Message-ID: <20240802235617.7971-6-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643157259116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsdload.c | 2 +- bsd-user/elfload.c | 3 +-- bsd-user/qemu.h | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/bsd-user/bsdload.c b/bsd-user/bsdload.c index 5b3c061a452..dcf3ca14fcc 100644 --- a/bsd-user/bsdload.c +++ b/bsd-user/bsdload.c @@ -193,7 +193,7 @@ int loader_exec(const char *filename, char **argv, char= **envp, && bprm->buf[1] =3D=3D 'E' && bprm->buf[2] =3D=3D 'L' && bprm->buf[3] =3D=3D 'F') { - retval =3D load_elf_binary(bprm, regs, infop); + retval =3D load_elf_binary(bprm, infop); } else { fprintf(stderr, "Unknown binary format\n"); return -1; diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c index 833fa3bd057..caf8a1adf2d 100644 --- a/bsd-user/elfload.c +++ b/bsd-user/elfload.c @@ -597,8 +597,7 @@ load_elf_sections(const struct elfhdr *hdr, struct elf_= phdr *phdr, int fd, return 0; } =20 -int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs, - struct image_info *info) +int load_elf_binary(struct bsd_binprm *bprm, struct image_info *info) { struct elfhdr elf_ex; struct elfhdr interp_elf_ex; diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index c7f78096734..f18a54cc933 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -163,8 +163,7 @@ int loader_exec(const char *filename, char **argv, char= **envp, struct target_pt_regs *regs, struct image_info *infop, struct bsd_binprm *bprm); =20 -int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs, - struct image_info *info); +int load_elf_binary(struct bsd_binprm *bprm, struct image_info *info); int load_flt_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs, struct image_info *info); int is_target_elf_binary(int fd); --=20 2.45.1 From nobody Sun Nov 24 11:59:45 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=1722643155; cv=none; d=zohomail.com; s=zohoarc; b=g295nlQuQ9jRNuP4A58QNaAMYtSXcoba1fgNxdRXwWMAAMKt7HDLdhJvgtoJRtcK221D4xbGug/YPLVmhzD2Xlbi4PDZVreON14yS80CaPV5gETyhycaGDAhKkCZf+EV1kDd2y1iSgFxazTpfuMD8/uHt85eLLz6VpwmPBPprsY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643155; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Rl/znR7UzS/Jv1fIJnzwl/xusVFEIhdoOvswwLVsMsA=; b=QWflBhaLHENz2+2a0bAo3hMkB27+9w1H8nH4R9AH96oqCf5JjEKt94aWUcmaj68Lg+j1rFdLTCPdWw94iC2+8zkSMSE7hWkUA4vEcWdq5wSiR1eMBW/2zC8BXNQhvu7m+FnHaYOLOB/Btz3v9WRJM+WaWQZgIe19CHwz41VZa/E= 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 1722643155803410.62257088658237; Fri, 2 Aug 2024 16:59:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29m-00028q-He; Fri, 02 Aug 2024 19:57:58 -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 1sa29c-0001ab-GC for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:49 -0400 Received: from mail-io1-xd2a.google.com ([2607:f8b0:4864:20::d2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29b-0004HO-2B for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:48 -0400 Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-81fe38c7255so3105639f.1 for ; Fri, 02 Aug 2024 16:57:46 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643065; x=1723247865; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Rl/znR7UzS/Jv1fIJnzwl/xusVFEIhdoOvswwLVsMsA=; b=uwtlK/fX+94kU5k4vg0on7GeGwp7+c598sPaMm/OclVl85tfkY+ki+xvDjSacUwRqr PLnvRygKLBLPXTApyBzQ/UevYmhBIOgGuix42MhvXbdHN+oWI84iyzN1OT09I1AfeKgN KbctEh0cHAi1E8STU4M0SIxZup+aaGcss75hEFPHvtUrjXe8ymyGbvclOGZgJkBX44XH gnBjcPr10UWA1SHn2kGSK7J346vZXrOKOe3thmz7i5BWwAPD9ea+Q/Sna8Glwl8QBZDt YEjQsUar1GZMzyenIwIbVJYoHIBkoJIeECFNcfokEeammSQw8IzeVVRQI8oRDOdfEDm7 suMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643065; x=1723247865; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Rl/znR7UzS/Jv1fIJnzwl/xusVFEIhdoOvswwLVsMsA=; b=qMGkvHv/JyUmP3ljwBE6iL3njmBa/hzDkTXaThb8BtHKxUwQaJ3IaghIwMDUfLPrss h5Ak0kdKmZCj8VYTW/mLBbi+8JV6r2pUcZuAzNgrtYAYfAXft0kujVo4jzFQDz9FfxW2 1CkJE/Hp4mlEGD6P6rdRfovydeBl+pVAJ9zFakgobmsyedyXLshZCNZYXofW24+LTFxz gsGpv+sdjyXvZGhhOji8mosdybTfaxywZEOC2kHaoZmo1vkatQaewQfkgltPiIFyrPnT ZXz3jwkdNNc50ts0VDOcRbvq9nhvNHO1tsNDTdJzf0vWEtWzhUr9ElbD0ZVjNbABNJsK XPTA== X-Gm-Message-State: AOJu0YwKtfzZ+PcpDkqCC+bNSn74k7Bh+ye1E2qHgo8Fenl5uqd0Q9PJ gQDhkHy08szuXao9XY61bEHBJ3XzO1wJYFxxchdoXKxNe1iwKxrF27Xb/fOZB3s8fK64sVohWBR l0+k= X-Google-Smtp-Source: AGHT+IHaBirxAvRkwv2oRYt0555cjDOxoNSL52MbfDWjzhkOB1rTzgoq1htIwlyMZjYQI2GYbekYqA== X-Received: by 2002:a05:6602:6c09:b0:803:85ba:3cf9 with SMTP id ca18e2360f4ac-81fd437127bmr663467339f.10.1722643065590; Fri, 02 Aug 2024 16:57:45 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke Subject: [PATCH 06/17] bsd-user: Remove load_flt_binary prototype Date: Fri, 2 Aug 2024 17:56:06 -0600 Message-ID: <20240802235617.7971-7-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643157250116600 Content-Type: text/plain; charset="utf-8" bsd-user doesn't have support for loading FLT binaries. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/qemu.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index f18a54cc933..b97a902a4c2 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -164,8 +164,6 @@ int loader_exec(const char *filename, char **argv, char= **envp, struct bsd_binprm *bprm); =20 int load_elf_binary(struct bsd_binprm *bprm, struct image_info *info); -int load_flt_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs, - struct image_info *info); int is_target_elf_binary(int fd); =20 abi_long memcpy_to_target(abi_ulong dest, const void *src, --=20 2.45.1 From nobody Sun Nov 24 11:59:45 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=1722643116; cv=none; d=zohomail.com; s=zohoarc; b=CO8z16rP+JsVbfEeIHXpmXyJAUhzpDLSud3q4/TuUpFqXzFTphNBQIePob6VCamTyjgXefi7OjBNarYimUnti2Ftv/dBARaTAlGUNYXkFIlkSTzcTcI6Viqp/2lMrTzx4zhopk7KvGdEqnbdkwy1wg7s602vpuGllYmRDlzA0Ec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643116; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ARXUdRtW9JUYDBe/PGc2EUZh9mbaCTufkya2rCFHUZQ=; b=gTKycVKbDwWbfObA+GUVR+u5GtaF4nKSUUH91gyBe/OCZDNOqSOHT82aTUUOTfJZez++g46dnCq+GT3NkAToZBMQN16sfmiQezJTTb6b/0MCpMKWG2LWhxnfxVs0HY5EC4u5NAeGcSQVJVM72MUb7JjcdSheen1ckMj64a1bEXQ= 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 1722643116586303.67113421927957; Fri, 2 Aug 2024 16:58:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29k-00020j-N5; Fri, 02 Aug 2024 19:57:56 -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 1sa29d-0001en-Gb for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:51 -0400 Received: from mail-io1-xd2d.google.com ([2607:f8b0:4864:20::d2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29c-0004Hm-2m for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:49 -0400 Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-81fd1e05a5aso92144839f.0 for ; Fri, 02 Aug 2024 16:57:47 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643067; x=1723247867; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ARXUdRtW9JUYDBe/PGc2EUZh9mbaCTufkya2rCFHUZQ=; b=Kds3UqA9UUv2PDtcSSJjaNZwFHeZvU7RQFOkgeV1av6J9IMJRly5BT8J6QSZRhw3Yk cK16uppq1XU77/sH7tcQB6C3Xslj2ZPlarrULYGi3Mjb/44aHAuOoyvjwP25HwZ9mrQl j2kULE0G4HVPJRnoPTPfOouvfFaqmAj3PWSF5SvvzWlbonrpnU0gMjsgamqkiJ4aJZvO rQ8go1OeDum0X88toXGiSIzSN0LI9SvY0qUmvKI8ZeC2/7IuNGLRsOKAZlHFGLnxlNn2 /WWWE1RyhknuhxaRd3cZkQy+mTzFvz+ovzo0srtYqA0X39S8BiV5ReeuPfa2cBjrL/ZG vQtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643067; x=1723247867; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ARXUdRtW9JUYDBe/PGc2EUZh9mbaCTufkya2rCFHUZQ=; b=NJOaDsOrfY+VTtMapUh1x0ESkKH6o0yDceYf990KfxqxQnVv9bWvTKvp8SF+u+oDHS iyF6Hltz46YjDImZeHL6vWmnUOVcozUzipOXPzd39YoSDQKFdNfqojenIZbDWb5QBFJx CpV/UTiAs/AiUB/Y8o0ky5Y6MOVOnUoHEZUzJnNHMwzzBxpjAubcMSzsi2G2sQnslXVn uD38iZGaKY2K7bUaRqjg7dvGKREXzQQmMTZLveq3tBqT9FLWX8Nz+eyyflW3xD+dey4y l7E9+fuu9Lv5tEt8SPnpggQxicSUE+7ZKt+pyH92esVbqm2XeEgImcVyraiHmjHt94Pb onHA== X-Gm-Message-State: AOJu0YwhKJApy9TUVPGinX8wNIW1ryqNL3O/QR5NCYM7NcUlsEHKF1VS 4NWKJG6bmGiZKZe42nYiQevWj8gRDchpWq+dzcw97OwtHmthrIbJ3YjBcbzPk4O1cYLPGP93cmW 1k7E= X-Google-Smtp-Source: AGHT+IGJ8kBl1jAk/AiBp+gXJapmmr90k+KYMEUr1aXQGBzm5v5FOeHeCD46xd5FHzwZ2op+oj4ZNg== X-Received: by 2002:a05:6602:1512:b0:7fc:89ed:c15d with SMTP id ca18e2360f4ac-81fd43e16a7mr672562239f.13.1722643066686; Fri, 02 Aug 2024 16:57:46 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke Subject: [PATCH 07/17] bsd-user: Remove deprecated -p argument Date: Fri, 2 Aug 2024 17:56:07 -0600 Message-ID: <20240802235617.7971-8-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-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::d2d; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2d.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643118865116600 Content-Type: text/plain; charset="utf-8" FreeBSD never really used the -p argument, so it's safe to remove entirely. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/main.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 9ad31bd1efe..709ab10ddc1 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -388,14 +388,6 @@ int main(int argc, char **argv) } } else if (!strcmp(r, "L")) { interp_prefix =3D argv[optind++]; - } else if (!strcmp(r, "p")) { - unsigned size, want =3D qemu_real_host_page_size(); - - r =3D argv[optind++]; - if (qemu_strtoui(r, NULL, 10, &size) || size !=3D want) { - warn_report("Deprecated page size option cannot " - "change host page size (%u)", want); - } } else if (!strcmp(r, "g")) { gdbstub =3D g_strdup(argv[optind++]); } else if (!strcmp(r, "r")) { --=20 2.45.1 From nobody Sun Nov 24 11:59:45 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=1722643155; cv=none; d=zohomail.com; s=zohoarc; b=RGqd18uobcNQcQTS+y/T/GNDofRhtI+UFx9of03DLs1oFvQcPAQfKEc5q87nH2gm3zqulHag1fZubhwlWa8lC7rJAPZFav+sHEcTiphH6VIcCP3dmTMtgjpYgv+E7bTkGs352Wwh02MpOodilfDEp9zWiPUxxyhX7CGMDMY4WqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643155; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1Z2vd5lroKGBHrik7P/5HRr5owaUTXoIaCHxzqNr690=; b=YTLfJ50Wqd5d+nvVVlfDQjuXm1Sisn4rN6XPYRHBHWZPTurMVFKVdnG+nO6I8P1e/8i1d20E4q3/y5MCrErMKt0S4tlg2f/5z5lr8VNRfCLX12vnkjqLTssvjCnsYudv4Xi5F5fkpX76I/k/XLpNWbcFiYIhWzA5yCRf1fTTUDY= 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 1722643155946279.30078034688336; Fri, 2 Aug 2024 16:59:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29k-0001yL-0R; Fri, 02 Aug 2024 19:57:56 -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 1sa29e-0001im-M2 for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:51 -0400 Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29d-0004Hw-7n for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:50 -0400 Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-81f8d644fe0so244061139f.1 for ; Fri, 02 Aug 2024 16:57:48 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643068; x=1723247868; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1Z2vd5lroKGBHrik7P/5HRr5owaUTXoIaCHxzqNr690=; b=qhCGpuAdibP4XNbdwE92QWhyB+i56ZQVg1SbT2ZiPyyMI9iXatSuLeUdLl8s4ajXG5 xB+mdGOIddbmfyqe38O08bVfrBawokFNaj1yXcbjU0BhHXSOs+C+rLpCx8odrY4olUQ6 BHYLIZ2e8ViPnEL/erp4WQOfZrgZIrWndF9uHkKsR1to55klEk48z/GW2GOnJYpoH9dX TvDuAnsZXc/zPqWYm2okDAxa4aNlh0Uihj2Q2HypqTnqpwCrHW8OfDrL3rEIK/6ZtfTA mdnzQHwYVOe1EQplXywDCFKEzSDDo85L5YRUBAaUPjIGWqxB7X4cFyzXffUeTmBNIgAi 3F4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643068; x=1723247868; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1Z2vd5lroKGBHrik7P/5HRr5owaUTXoIaCHxzqNr690=; b=h0c6PF3UfVC8RlSlOogYAJ9IwcURdZq9UKCqyySiUCA58yGjz1ubB43YSj0XsbeiYI zwa+di2U8TeBUHShZmOZp59tfSR1QsW3T7E5VPQnw9KVo26o6u9crOT149yzS5i5QC0+ Gv7uXAFuiqbVTip7ALv7JmcvpQ+Y7mtLRtDuuWv3lPSk0pPz0SSh49FsX8J3IAXiNto5 3C9pNBnriJHTWHx5vDwoknGoyaLFoPDVGku5zy5a4VObQN+9oDqnyrJ/SecvU7mNjEhB iz3YiGj0VKz8ClQxs3s/1p/ERyPhYy77U4dUiM5CYQ1dCP/HPH5a049wkrC6z7upshIc C3wA== X-Gm-Message-State: AOJu0Yxtl8MjJk1BBL+xF3cGHO+h9KamlmBgv0uhSBFGACxe2FDlJPDs anLjee9Y7HrmmNCHdGCwqNNFsP6B5+VM2TSiuY8vn6DtwlNjbuSPzlDbPO61x/9KLucYYmVhoIJ GUIg= X-Google-Smtp-Source: AGHT+IFopvDLL12aWDbRW2rUu2u/fJ2ptES83fR6pOQKS/EQQxVz/dSQbgCiu2yG+ePVF9jkTnCjIA== X-Received: by 2002:a05:6602:341f:b0:81f:8bed:702f with SMTP id ca18e2360f4ac-81fd4353a65mr629795739f.1.1722643067821; Fri, 02 Aug 2024 16:57:47 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke Subject: [PATCH 08/17] bsd-user: Eliminate unused qemu_uname_release Date: Fri, 2 Aug 2024 17:56:08 -0600 Message-ID: <20240802235617.7971-9-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-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::d36; envelope-from=imp@bsdimp.com; helo=mail-io1-xd36.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643157256116600 Content-Type: text/plain; charset="utf-8" bsd-user has never supported this, and FreeBSD make it easy to set this on a per-jail basis, so that the normal reporting routines that we pass through just work. Since this was never used, and never even in the usage(), retire it to cut down on the clutter. It was literally just a write-only variable. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/main.c | 3 --- bsd-user/qemu.h | 1 - 2 files changed, 4 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 709ab10ddc1..8c52fb43ff1 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -92,7 +92,6 @@ static const char *cpu_type; unsigned long reserved_va; =20 const char *interp_prefix =3D CONFIG_QEMU_INTERP_PREFIX; -const char *qemu_uname_release; =20 unsigned long target_maxtsiz =3D TARGET_MAXTSIZ; /* max text size */ unsigned long target_dfldsiz =3D TARGET_DFLDSIZ; /* initial data size li= mit */ @@ -390,8 +389,6 @@ int main(int argc, char **argv) interp_prefix =3D argv[optind++]; } else if (!strcmp(r, "g")) { gdbstub =3D g_strdup(argv[optind++]); - } else if (!strcmp(r, "r")) { - qemu_uname_release =3D argv[optind++]; } else if (!strcmp(r, "cpu")) { cpu_model =3D argv[optind++]; if (is_help_option(cpu_model)) { diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index b97a902a4c2..ed6044cfdaf 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -122,7 +122,6 @@ struct TaskState { void init_task_state(TaskState *ts); void stop_all_tasks(void); extern const char *interp_prefix; -extern const char *qemu_uname_release; =20 /* * TARGET_ARG_MAX defines the number of bytes allocated for arguments --=20 2.45.1 From nobody Sun Nov 24 11:59:45 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=1722643204; cv=none; d=zohomail.com; s=zohoarc; b=eLcWcjnFkdpWerPC5zqPW2QYdaThbGze8md8eqPWwAh+TiZPHq4GhHeom7VyuDyTuVSoL5/qbX4M4oGnHY/QMEg6qS1ICEW+E2ZhTWjJ5hRRRxAIiBo0JFuwgZS5FzPNijOiq9MJ5PN0ZwFL4x7iMbSoLsDAQkwDuL1Sx82UcOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643204; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rilSw23IUxG4CebVk69zBKPwzGm7q3B46BwudSTr67M=; b=K1sZY40JLEeWncJEnCwX1vqxVJJAf3PL+Bt4QGqYjJbnqXB2PzFWlP9y9snVmMYicPslESBErCXhd4gBB8Kp1fC6GTzjxvxmJdSFOaFBNO+ADodgE6ptPQ3GvuGpyfQd5wHjKt1GYn/vf7ynu5bHk0cKCwK70b45B+IYXEUewr0= 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 1722643204278764.7444614755154; Fri, 2 Aug 2024 17:00:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29n-0002Ci-I1; Fri, 02 Aug 2024 19:57:59 -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 1sa29f-0001lm-SY for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:52 -0400 Received: from mail-il1-x12f.google.com ([2607:f8b0:4864:20::12f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29e-0004I8-DA for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:51 -0400 Received: by mail-il1-x12f.google.com with SMTP id e9e14a558f8ab-389ccd2f0abso39916795ab.2 for ; Fri, 02 Aug 2024 16:57:50 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643069; x=1723247869; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rilSw23IUxG4CebVk69zBKPwzGm7q3B46BwudSTr67M=; b=zM0uKIvPULjOb0wxLy5mD/n+uE5OS8ACWmF6ahkv32jSQKzfqiuVmzXLL4XRpToYec ggP3DF1dddApFcFMPqb00dCCrBsVEZSXs7TdEt6EhA1gGU1gdrgpNyJKhAdNneNjn6rc D1lb4FkjkJjRvZFgwAykeyqUPgQTcukfF8/+6iQom+A0GCu6kYvcnO+MEpNZXQ5/DjEi Df7/6346a52GP13ZVqkzS1ZYHKuCWjcFalhTOZtMVV3PS5IIJ48Co8YYPuOhs9FPKRLv +CXiI4JhGioDLZ1UdVtaoFQsCKf27oQQ4bpgJxhHyblzOtv6kt5br6s6IigV3vOH2OKV V/iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643069; x=1723247869; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rilSw23IUxG4CebVk69zBKPwzGm7q3B46BwudSTr67M=; b=V9jm28GK36HDIAIwpGZQcTlAR2fCUC/pQUC01ApBat7iXGBeFYZM14MVj2bdgzqfUr tcHgyfM2VF9iFTnEgRl74Qd4PE/6Zp2MaXIHtlRWzXZpTX+9p/JGXRPg78dJvcZ3AEZe 6X9DUsQzCTomhPS8nlSijctaAG/t1ISLfD4BcRRja7ZCXsDocGazYV7fi+i6ep4WNIx3 r1aptKx8+27ufzCmtMaWr/CgS1bkehG4HHxOn/FC+G95hXC+yCOUvnuOkhmd3FuDu/J5 9MWr6xgKh1vl9If0DEl3PHKXdyY6efcxz7Jf8W7mPS71axLjuvs0STKuGxGcoAXf+hi2 1JTQ== X-Gm-Message-State: AOJu0YzLKIH+q6iim0K0zQ1OuVilqX1LOogIdJODVDhesyxls0+FdoNz HjIgxkvuifjvfR18VbdenfhkAOh7b8t1OANwa+/Si+oIZe7GsUHdCmyDkk1INLoBuMbE9dfzs+t 9vvk= X-Google-Smtp-Source: AGHT+IF1oU7ZT1YmVXaX8TPsKGeKDUWjF16N1xXfjP6JDckPPTwnVGYNqVT7GbbGzj5XK+RX6EugHw== X-Received: by 2002:a05:6602:27cf:b0:812:9c27:357c with SMTP id ca18e2360f4ac-81fd43652b4mr808622239f.8.1722643068819; Fri, 02 Aug 2024 16:57:48 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke Subject: [PATCH 09/17] bsd-user: target_msync unused, remove it Date: Fri, 2 Aug 2024 17:56:09 -0600 Message-ID: <20240802235617.7971-10-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-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::12f; envelope-from=imp@bsdimp.com; helo=mail-il1-x12f.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643205242116600 Content-Type: text/plain; charset="utf-8" Nothing calls target_msync in the upstream or blitz fork, so remove it. It will save us having to modernize it. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/mmap.c | 17 ----------------- bsd-user/qemu.h | 1 - 2 files changed, 18 deletions(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index f3a4f1712da..fc69cb43ebd 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -739,20 +739,3 @@ int target_munmap(abi_ulong start, abi_ulong len) mmap_unlock(); return ret; } - -int target_msync(abi_ulong start, abi_ulong len, int flags) -{ - abi_ulong end; - - if (start & ~TARGET_PAGE_MASK) - return -EINVAL; - len =3D TARGET_PAGE_ALIGN(len); - end =3D start + len; - if (end < start) - return -EINVAL; - if (end =3D=3D start) - return 0; - - start &=3D qemu_host_page_mask; - return msync(g2h_untagged(start), end - start, flags); -} diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index ed6044cfdaf..a2bc14eea50 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -236,7 +236,6 @@ int target_munmap(abi_ulong start, abi_ulong len); abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, abi_ulong new_size, unsigned long flags, abi_ulong new_addr); -int target_msync(abi_ulong start, abi_ulong len, int flags); extern abi_ulong mmap_next_start; abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size); void mmap_reserve(abi_ulong start, abi_ulong size); --=20 2.45.1 From nobody Sun Nov 24 11:59:45 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=1722643174; cv=none; d=zohomail.com; s=zohoarc; b=d+EFc3EzY0tfSU0INanbb+pRUq5o8q4tPheTpciC4KZ7b6+08Kqjaqcb3gmZ1ls9DwbzulFWP5aPQdi0oYUHCNC5JXgArkOsZ82se/e9QXb4NkyI0V6X+hMLu7NOUcUIrIy5cchCewv955ntzZL7VQ71+thZ4uNY4qR+h/LH2HE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643174; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=h8/T8Zg48KUN7dtjWNUDu011IwEcHhj9Ls+BvEab5T4=; b=N1Aw/gN+rHuE2W2gXWo6PoyYoWuNOW7O5jh/cxSy0/8vVvMyJ8RcblalPPK7p52MU1nxGkG3cflbE7eLuqecbi6vt5F894j+GJe4vddTUtpVC10pYgvuS5bPG7BerT2un3tn/r5VgLDOCwq66xF7ZyrRhnuquTyFecllEmf+Y0g= 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 1722643174760575.8965095932124; Fri, 2 Aug 2024 16:59:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29p-0002M6-Kl; Fri, 02 Aug 2024 19:58: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 1sa29h-0001pz-97 for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:53 -0400 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29f-0004IU-FV for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:52 -0400 Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-81f8f0198beso363089939f.1 for ; Fri, 02 Aug 2024 16:57:51 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643070; x=1723247870; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h8/T8Zg48KUN7dtjWNUDu011IwEcHhj9Ls+BvEab5T4=; b=iP5jsyp48iBDvkuhUy7ioYtn6RFziXLGpW9UuMy/P0R7npximG3M464GeGEUiuEA+5 okbqoIL6VD/qA3RhmM29CfaDcdeKrgrtTLOmtPxlr9IJ2Qj4wmtNehQMLXZNP76TJfaR Xa6AB6f6H2p4G9ZKnsghhgzaqOvYCfEYz21Jd8ObYmWkxzLzONlfdW+bIALj5NZ1deGn Xx/z4ByoLC/2dldT2Cl7RIMfv22QXQ5p+amlgANyVFbmMXMXQNbSUOtbffMNydF3Zi/D DMyRQWf34XCzC2JugX2mkN7dQO9no1DIU/sD8Qi7dK6yuzs6q9ayE+gda6VPaEwNtc6t 7V8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643070; x=1723247870; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h8/T8Zg48KUN7dtjWNUDu011IwEcHhj9Ls+BvEab5T4=; b=bjs5HI9kprb1Lejl9BbKXJg/9emtOSajV03MzfmX4Cr5tXoUwrg4ccW08dZbn+OVN1 e5OLLf2KJoEdqO0WPqeRyOiSpf7QwmXSZl9AAFU1xOEurP0shg5jSYOrEaq8svPoVi8A HRD3FSzzxciT2pg3IlOmoJvo2SQDF40/5nYlNgt8OC1NMJr7YuD/1A4ery9/c26OwLfl BjkBgj6Kgi4QleTNbz7iUUmt+vrzOgX9GzJal+2dSmvf9qQ+f2WU8+pStK219J96c5ZS ZFnTnvXZXS95Q3lUWYb/BfU80ecZ0UxGt5X3syjI4YmEO5MXAvXH0rssb3oWG8J9XM8z J9hw== X-Gm-Message-State: AOJu0YyTB35YcV/K74zngfji3EuHgPB3IAjvsGPQ/c3T7YCoQfkYY+hI SL+kI8qemYeJ5ucgqecZJcKAz5xwlERxjjTEwYpl/VpwWw4avdW5jCdFTvaX0znND4T7MX1XzdS 4Vro= X-Google-Smtp-Source: AGHT+IFypnwCX92FWsXd9Iwc3Ip+JeDls2I4arRl7Tzy3Hr7pVFB8PfUcwlFTGxdjuPbwqi8Vdp2Wg== X-Received: by 2002:a05:6602:6d17:b0:81f:9328:9631 with SMTP id ca18e2360f4ac-81fd434decdmr572602639f.2.1722643069922; Fri, 02 Aug 2024 16:57:49 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke Subject: [PATCH 10/17] bsd-user: Pass image name down the stack Date: Fri, 2 Aug 2024 17:56:10 -0600 Message-ID: <20240802235617.7971-11-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-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::d2b; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2b.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643175054116600 Content-Type: text/plain; charset="utf-8" Pass the image name down the stack so that we can give better error messages. Inspired by similar work in linux-user, and more likely to come. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/elfload.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c index caf8a1adf2d..dba03f17465 100644 --- a/bsd-user/elfload.c +++ b/bsd-user/elfload.c @@ -36,8 +36,8 @@ abi_ulong target_stksiz; abi_ulong target_stkbas; =20 static int elf_core_dump(int signr, CPUArchState *env); -static int load_elf_sections(const struct elfhdr *hdr, struct elf_phdr *ph= dr, - int fd, abi_ulong rbase, abi_ulong *baddrp); +static int load_elf_sections(const char *image_name, const struct elfhdr *= hdr, + struct elf_phdr *phdr, int fd, abi_ulong rbase, abi_ulong *baddrp); =20 static inline void memcpy_fromfs(void *to, const void *from, unsigned long= n) { @@ -268,7 +268,8 @@ static void padzero(abi_ulong elf_bss, abi_ulong last_b= ss) } } =20 -static abi_ulong load_elf_interp(struct elfhdr *interp_elf_ex, +static abi_ulong load_elf_interp(const char *elf_interpreter, + struct elfhdr *interp_elf_ex, int interpreter_fd, abi_ulong *interp_load_addr) { @@ -335,7 +336,7 @@ static abi_ulong load_elf_interp(struct elfhdr *interp_= elf_ex, } } =20 - error =3D load_elf_sections(interp_elf_ex, elf_phdata, interpreter_fd,= rbase, + error =3D load_elf_sections(elf_interpreter, interp_elf_ex, elf_phdata= , interpreter_fd, rbase, &baddr); if (error !=3D 0) { perror("load_elf_sections"); @@ -526,8 +527,9 @@ int is_target_elf_binary(int fd) } =20 static int -load_elf_sections(const struct elfhdr *hdr, struct elf_phdr *phdr, int fd, - abi_ulong rbase, abi_ulong *baddrp) +load_elf_sections(const char *image_name, const struct elfhdr *hdr, + struct elf_phdr *phdr, int fd, abi_ulong rbase, + abi_ulong *baddrp) { struct elf_phdr *elf_ppnt; abi_ulong baddr; @@ -764,7 +766,7 @@ int load_elf_binary(struct bsd_binprm *bprm, struct ima= ge_info *info) =20 info->elf_flags =3D elf_ex.e_flags; =20 - error =3D load_elf_sections(&elf_ex, elf_phdata, bprm->fd, et_dyn_addr, + error =3D load_elf_sections(bprm->filename, &elf_ex, elf_phdata, bprm-= >fd, et_dyn_addr, &load_addr); for (i =3D 0, elf_ppnt =3D elf_phdata; i < elf_ex.e_phnum; i++, elf_pp= nt++) { if (elf_ppnt->p_type !=3D PT_LOAD) { @@ -780,7 +782,8 @@ int load_elf_binary(struct bsd_binprm *bprm, struct ima= ge_info *info) } =20 if (elf_interpreter) { - elf_entry =3D load_elf_interp(&interp_elf_ex, interpreter_fd, + elf_entry =3D load_elf_interp(elf_interpreter, + &interp_elf_ex, interpreter_fd, &interp_load_addr); reloc_func_desc =3D interp_load_addr; =20 --=20 2.45.1 From nobody Sun Nov 24 11:59:45 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=1722643197; cv=none; d=zohomail.com; s=zohoarc; b=mf7FHD26R150hMmrDKYJX7nFBFKaTnTDZt/VPur5ccifDxwFU7nnm2XlIBzJ+RwUwL14RMpb31j/IikHgNEsl0+GNwN7bnqw91FpWaGKMG4quptrICQvIe/85uznOp8kV/qt8bIC4XMFucMLUqPvOGtEdVS/EeBE2KWJgz+rEZ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643197; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TjbYI1GPGe/HLcBnpiBAspcHBUxaAboZV8ZlqCzZd1k=; b=JSDJoIy0O1S6rkSMaaXc27S0JM9zgIB+ShaORzWHckW71BSXpRKMPIhhJnWpVAJJsjygFWU8sPEAWsdshYlP0eEySB7mXx/U9onIxocxUcvjy9j/+PCBWxmt52H7FXfWfKjSQLeGas+CSLAsC41wCRiCJrvbv+Do2w7+gJfe0Mc= 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 172264319796064.02850722516041; Fri, 2 Aug 2024 16:59:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29m-00028R-Eg; Fri, 02 Aug 2024 19:57:58 -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 1sa29i-0001v3-UY for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:55 -0400 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29h-0004Ig-5W for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:54 -0400 Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-816ca307407so312545839f.2 for ; Fri, 02 Aug 2024 16:57:52 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643071; x=1723247871; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TjbYI1GPGe/HLcBnpiBAspcHBUxaAboZV8ZlqCzZd1k=; b=IZe76LRgTSdEyrt0fwGPQr/goaaKWizEQ41962lMp5dhGcdPvcDY3/RBCBlokgP5L6 yGf406QpWu/rG9kjWQ9mCE3K1Bl/VMjR+hsiPFUC9boUqGLrCa/XffZ/dg+1t9VeBDA/ IiHMjzAykLAQT2NAF+gCh7z4EXViPDtwV/bQeEWZoxOyUPioHpqTOpFQEID6+R7Av7yQ 8quYXB7vJ7Jps5r+fhir79cf3rgfub2ODjCA9/PBu3BJze9aI3LwHJttj80mTlYpQYb9 hWOfFCnl7lRe86kBDQ2rYAyXa83Itv1TsuQE1PoZZGUaCLS4HAw3xYBO0TszYN6Mgome gjmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643071; x=1723247871; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TjbYI1GPGe/HLcBnpiBAspcHBUxaAboZV8ZlqCzZd1k=; b=itn4VR1B/Bmt2jWVZbdK2QSAEHnrRrIxVILzo1z0C2XNHhYdhKePCNp8zmquut3HIZ Vm8787g3W7JFWIjoQrY2YQfhX82UF5TQ4d7HFLjO+veo1BHbdAaTl+d1J1GHol7wncfL KfMo92e+txRsWQlqh8cLURKDg1CExH5U2wtAIIWwPVgO3vDHRR/0+beaiyWxiaZ6GvOx 0J15gvutJDNQLVm2bkcHptCNh/cvUhi8j3mFGl6CZ8SaZNoDvcPgaSaVEelYTsexnwur xjye4Ri8l8HjplkcsBNLohFe1J5MzjUuMs3TTnKDl+8iXkD0ZNoTWcu1LoSy16xaP3gI RSdA== X-Gm-Message-State: AOJu0Yzk1umj4KBO/B7RpCLukOuwGoK1lZMPmTHjA4KMkMP70vsxJMPk sQsJHxNomLFwe/Pynvl6OW+ekD+4kUAf2rJSqxORMny3yMfrDDUa8yk+B+2nX3jur1zrueMz8Jo urOM= X-Google-Smtp-Source: AGHT+IGMEnGvMZZf/FOf0oDjclI6BfkucF5WiUzCWNtQV5GP906acktYZ3lTS76EuIDskNQ5F4kgBQ== X-Received: by 2002:a05:6602:3fcb:b0:7f7:d2c7:3b7a with SMTP id ca18e2360f4ac-81fd42b7b96mr624313039f.0.1722643071078; Fri, 02 Aug 2024 16:57:51 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke Subject: [PATCH 11/17] bsd-user: Replace set_brk and padzero with zerobss from linux-user Date: Fri, 2 Aug 2024 17:56:11 -0600 Message-ID: <20240802235617.7971-12-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-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::d31; envelope-from=imp@bsdimp.com; helo=mail-io1-xd31.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643199445116600 Content-Type: text/plain; charset="utf-8" The zero_bss interface from linux-user is much better at doing this. Use it in preference to set_brk (badly named) and padzero. These both have issues with the new variable page size code, so it's best to just retire them and reuse the code from linux-user. Also start to use the error reporting code that linux-user uses to give better error messages on failure. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/elfload.c | 110 +++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 53 deletions(-) diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c index dba03f17465..0a2f2379c93 100644 --- a/bsd-user/elfload.c +++ b/bsd-user/elfload.c @@ -22,6 +22,7 @@ #include "qemu.h" #include "disas/disas.h" #include "qemu/path.h" +#include "qapi/error.h" =20 static abi_ulong target_auxents; /* Where the AUX entries are in target = */ static size_t target_auxents_sz; /* Size of AUX entries including AT_NUL= L */ @@ -210,62 +211,63 @@ static void setup_arg_pages(struct bsd_binprm *bprm, = struct image_info *info, } } =20 -static void set_brk(abi_ulong start, abi_ulong end) +/** + * zero_bss: + * + * Map and zero the bss. We need to explicitly zero any fractional pages + * after the data section (i.e. bss). Return false on mapping failure. + */ +static bool zero_bss(abi_ulong start_bss, abi_ulong end_bss, + int prot, Error **errp) { - /* page-align the start and end addresses... */ - start =3D HOST_PAGE_ALIGN(start); - end =3D HOST_PAGE_ALIGN(end); - if (end <=3D start) { - return; - } - if (target_mmap(start, end - start, PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0) =3D=3D -1) { - perror("cannot mmap brk"); - exit(-1); + abi_ulong align_bss; + + /* We only expect writable bss; the code segment shouldn't need this. = */ + if (!(prot & PROT_WRITE)) { + error_setg(errp, "PT_LOAD with non-writable bss"); + return false; } -} =20 + align_bss =3D TARGET_PAGE_ALIGN(start_bss); + end_bss =3D TARGET_PAGE_ALIGN(end_bss); =20 -/* - * We need to explicitly zero any fractional pages after the data - * section (i.e. bss). This would contain the junk from the file that - * should not be in memory. - */ -static void padzero(abi_ulong elf_bss, abi_ulong last_bss) -{ - abi_ulong nbyte; + if (start_bss < align_bss) { + int flags =3D page_get_flags(start_bss); =20 - if (elf_bss >=3D last_bss) { - return; - } + if (!(flags & PAGE_RWX)) { + /* + * The whole address space of the executable was reserved + * at the start, therefore all pages will be VALID. + * But assuming there are no PROT_NONE PT_LOAD segments, + * a PROT_NONE page means no data all bss, and we can + * simply extend the new anon mapping back to the start + * of the page of bss. + */ + align_bss -=3D TARGET_PAGE_SIZE; + } else { + /* + * The start of the bss shares a page with something. + * The only thing that we expect is the data section, + * which would already be marked writable. + * Overlapping the RX code segment seems malformed. + */ + if (!(flags & PAGE_WRITE)) { + error_setg(errp, "PT_LOAD with bss overlapping " + "non-writable page"); + return false; + } =20 - /* - * XXX: this is really a hack : if the real host page size is - * smaller than the target page size, some pages after the end - * of the file may not be mapped. A better fix would be to - * patch target_mmap(), but it is more complicated as the file - * size must be known. - */ - if (qemu_real_host_page_size() < qemu_host_page_size) { - abi_ulong end_addr, end_addr1; - end_addr1 =3D REAL_HOST_PAGE_ALIGN(elf_bss); - end_addr =3D HOST_PAGE_ALIGN(elf_bss); - if (end_addr1 < end_addr) { - mmap((void *)g2h_untagged(end_addr1), end_addr - end_addr1, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0); + /* The page is already mapped and writable. */ + memset(g2h_untagged(start_bss), 0, align_bss - start_bss); } } - - nbyte =3D elf_bss & (qemu_host_page_size - 1); - if (nbyte) { - nbyte =3D qemu_host_page_size - nbyte; - do { - /* FIXME - what to do if put_user() fails? */ - put_user_u8(0, elf_bss); - elf_bss++; - } while (--nbyte); + if (align_bss < end_bss && + target_mmap(align_bss, end_bss - align_bss, prot, + MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0) =3D=3D -1) { + error_setg_errno(errp, errno, "Error mapping bss"); + return false; } + return true; } =20 static abi_ulong load_elf_interp(const char *elf_interpreter, @@ -535,6 +537,7 @@ load_elf_sections(const char *image_name, const struct = elfhdr *hdr, abi_ulong baddr; int i; bool first; + Error *err =3D NULL; =20 /* * Now we do a little grungy work by mmaping the ELF image into @@ -579,12 +582,10 @@ load_elf_sections(const char *image_name, const struc= t elfhdr *hdr, start_bss =3D rbase + elf_ppnt->p_vaddr + elf_ppnt->p_filesz; end_bss =3D rbase + elf_ppnt->p_vaddr + elf_ppnt->p_memsz; =20 - /* - * Calling set_brk effectively mmaps the pages that we need fo= r the - * bss and break sections. - */ - set_brk(start_bss, end_bss); - padzero(start_bss, end_bss); + if (start_bss < end_bss && + !zero_bss(start_bss, end_bss, elf_prot, &err)) { + goto exit_errmsg; + } } =20 if (first) { @@ -597,6 +598,9 @@ load_elf_sections(const char *image_name, const struct = elfhdr *hdr, *baddrp =3D baddr; } return 0; +exit_errmsg: + error_reportf_err(err, "%s: ", image_name); + exit(-1); } =20 int load_elf_binary(struct bsd_binprm *bprm, struct image_info *info) --=20 2.45.1 From nobody Sun Nov 24 11:59:45 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=1722643167; cv=none; d=zohomail.com; s=zohoarc; b=O2tiDRYntUwoesDNlMoECFxxUlvjjy2CiLlaZw6iMxM2Zr/S3fNufbPlsaZYIMcbaRGWX/4yV59MUXdcCjFdQ50wUkwFcowfZun5herQzcBgWZL4Bm8zOV8j088IKJM2Fm49RWAJVt3ZcSQJZ8kjNqZyBI1h5lOyCpAG30LYrJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643167; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FWWgURm7Gj0tu0dmUrbtb+IelYe/G3vbyvbAbU8GzUk=; b=NeOCH01j+GMlvjecgrLPOsGvhLAxFZGr4u72PkpDewp1QFo6193RrK0iIAnrV3FcjPK5LTHFvqTNa2JEwqa2Bhxe2t84XF/O/U8gYXPwc2ZOmjzHqHFfZZ0K7I7cyhS2YBmC8KYEtYWKH0GR2G9GqFFjZAvWHJ1fdLQcYstwx24= 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 172264316786896.24881069467915; Fri, 2 Aug 2024 16:59:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29k-00021T-Q0; Fri, 02 Aug 2024 19:57:56 -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 1sa29i-0001un-MJ for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:55 -0400 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29h-0004Ij-9j for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:54 -0400 Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-81f9339e544so340310839f.0 for ; Fri, 02 Aug 2024 16:57:52 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643072; x=1723247872; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FWWgURm7Gj0tu0dmUrbtb+IelYe/G3vbyvbAbU8GzUk=; b=SlRtZFYgn2Sm0Z4CkP++WDMgwGwcL6y0mQkZNMvfs1yYk2rHbydrbYclXxxQHoyJ12 9nxERWeYWhXdB2RY6XbHxvdZsIveBGWuDTReHuFhcHIadvNDlOkGx1p8897jSj/P51Cv KuC6L2d+p5/TMAEq1Rw5yolvXgL+s/pArgeK6E0zdWKGbCpc2ni837BQ6cm0/ZbC5/m+ zKj2+OhwRu7FVA4/XrPWHLCbuexm0fMGHEujHCqiPvGwmGj/qMYo38CJn2NhzoRp8EBu EojJ+O5fzQHoBHUjWzzMCqcd83PzCv/pVEdimop4SgAdDlz5UGrLspBY7MS6mKYVpXNn 6PLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643072; x=1723247872; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FWWgURm7Gj0tu0dmUrbtb+IelYe/G3vbyvbAbU8GzUk=; b=SmZi6zf9uwArm1cfU7t3IHK9HjBr6wugYMy/ATyDB00kQulfl6N7b1WBzLCnDPLbdg P2E8Dq1Kix1H9uNjl2zmr6sgskWEPQHXwduAW7aBQQojx8myDvHytVhVD+o3T3MZHgEr NyQLPE+gp1s3Q54T/TVuEvOKbsrb18DZGrvCmwCQVYglAQqOiVfoLBiFPWg4FYvxho8p MSiqU53hW131M1Ul7sHRDHrC7MrUh7mI/idMdXEhSCRpX4hFtmaj875kbx1e3nxCbM/M 61g7NUbTGxbLfOGmYDv1FZ5N/ZeMtr1w0govODkhLU5JNz61Nk8Of9OwWvMp4eqA2ff+ GjGQ== X-Gm-Message-State: AOJu0YxjYsuAmGCxTHd/XVkcb0cJ8EOMmCTQeRsDnlB80lpiRx4uaepU xhl/A33Ch6pBMiz9TVHU3gpfJr39jNEPuVy1BaNlQ9ydAE29fuhuNxNeq4YW/vw5fv3Msf8+HBY UBKQ= X-Google-Smtp-Source: AGHT+IE2O5SY884IPHtNGxy0xYcbqgv0MSIy69f7/gVB/R2j7/TwQtot4my3nRkKDkWVvx0syz89hA== X-Received: by 2002:a05:6602:6016:b0:7f6:84e7:bd35 with SMTP id ca18e2360f4ac-81fd4358ef7mr535598339f.8.1722643071762; Fri, 02 Aug 2024 16:57:51 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke Subject: [PATCH 12/17] bsd-user: Use guest_range_valid_untagged to validate range Date: Fri, 2 Aug 2024 17:56:12 -0600 Message-ID: <20240802235617.7971-13-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-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::d2b; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2b.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643169054116600 Content-Type: text/plain; charset="utf-8" This is the generic validation function, so remove some hand-rolled ones. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/mmap.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index fc69cb43ebd..ed8d31a9048 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -74,9 +74,10 @@ int target_mprotect(abi_ulong start, abi_ulong len, int = prot) if ((start & ~TARGET_PAGE_MASK) !=3D 0) return -EINVAL; len =3D TARGET_PAGE_ALIGN(len); + if (!guest_range_valid_untagged(start, len)) { + return -ENOMEM; + } end =3D start + len; - if (end < start) - return -EINVAL; prot &=3D PROT_READ | PROT_WRITE | PROT_EXEC; if (len =3D=3D 0) return 0; @@ -689,11 +690,13 @@ int target_munmap(abi_ulong start, abi_ulong len) TARGET_ABI_FMT_lx "\n", start, len); #endif - if (start & ~TARGET_PAGE_MASK) + if (start & ~TARGET_PAGE_MASK) { return -EINVAL; + } len =3D TARGET_PAGE_ALIGN(len); - if (len =3D=3D 0) + if (len =3D=3D 0 || !guest_range_valid_untagged(start, len)) { return -EINVAL; + } mmap_lock(); end =3D start + len; real_start =3D start & qemu_host_page_mask; --=20 2.45.1 From nobody Sun Nov 24 11:59:45 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=1722643130; cv=none; d=zohomail.com; s=zohoarc; b=ABfOccgHxsahZdpi92xRn0HSU1p6bsFxsZjPZG0ioc2lPhfhfB2fiUHLpCEGqecVbBd8xE7SHtFM2QqMsKQBi83rPudLoGGEXaBDceFm+a+1qzftbeW1ohHUUzwdwnS3lH+LJo027cziwGIn5qHs21VtqO4FTp4RYzLCiGIovfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643130; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zcFCklOxEptK/v+KYBlk+aaUGmJl8I5KUjcP8oU3kVY=; b=CaR3KGI4d7REfynzNkCnanmvZUMZIuK4uzuY1/q1ipmf4yLRAt7Sf6jT1TefIdeisZFXUIe8MV11ZkVe48RlXVHVmOlapA/S4Y3BlHKM9kt6iy4m1ZrkhE7eTuvFYBnrNFQ906zqdjnRbo+meV8QVreXNjrfT1iVwSLcu5Y8ZmY= 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 1722643130417724.5938787806883; Fri, 2 Aug 2024 16:58:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29o-0002Fr-6x; Fri, 02 Aug 2024 19:58:00 -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 1sa29k-0001yw-4o for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:56 -0400 Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29i-0004Iw-Jg for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:55 -0400 Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-81f860c6015so357271139f.0 for ; Fri, 02 Aug 2024 16:57:54 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643073; x=1723247873; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zcFCklOxEptK/v+KYBlk+aaUGmJl8I5KUjcP8oU3kVY=; b=2Fi8EXtQ6HRAnNfojg+cnCpCMGSRD1JnurMQMhBkTVfAqc48PaHvoLs5i57Wr8zTED PdcRQUb+cOIEu4Vs4u6L0OqSuARDZRXHbru6ZtyW7IF5YLNYtB8JOSdY5NpZ8BrdfhOr 1A+PHupaJPOEMps0v34mfpDp3Jev73opLDNBicOknQepuntUqIbIMeQqRmTmCJyVKk0N vTfj+a3hHv4ii7iP8Gx3VUAPJxs71E7F3CvgDqvAK/vwc1LRUKeUvwuJwHxjNEBdocR+ b5XEef8iaHr5UYVByUhqPC9OglTytQ88F95B6Y6KsClj8hjOK0Ro9FX48oi4XHGnvnK1 aZTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643073; x=1723247873; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zcFCklOxEptK/v+KYBlk+aaUGmJl8I5KUjcP8oU3kVY=; b=EsKEDTckcnbgOVYVwIWb9q4VjMYFyM5y06S0W2Bth0USLf3ysdDft0LSo34lRkD9Qn twu+78CPoOM/YLNmgxB5YlB7WtcUIWt8Xr4VfasULEHQn4srm8MCtGLFNxb7iqgzLHD8 vQSm5hH/XacKuW1YwozVIqI66Xto3rEARc+4gdHEglDLlznQrLV1W+h1j2WfhtH55pcD nRw7KaKvsa6+zb5Cj2Hu3t4sDEc4cHAxHujyHBUI9ZtacLzl/F7eG8J3YIBXsGqv4fjN tFxmxMUQCnvLhRUbdamfLrAQhNq9KjiyEl1nEFfFzJ/S2ek7clvMyDHklqrncHBvuGRY D6sw== X-Gm-Message-State: AOJu0Yx4Fbjds2Q9+/Iiu71eusYbhYhM+oG+H62aWordM+IGmJ6q5i2H wYWv9JUaoh9oTrXWMwr2hr4Z5Vm10EMVMR/PgRvc6th3cRJ3ChftTVxykzud2ZBo+cxIbDiqZCg qkMQ= X-Google-Smtp-Source: AGHT+IF+T6AgLY1GQRi4nbq5nPAncJzm//ge4HtzBIoewlabZi/Bxkj8Q7QDmeCMupKHCP+kqJbo0g== X-Received: by 2002:a05:6602:27cf:b0:812:9c27:357c with SMTP id ca18e2360f4ac-81fd43652b4mr808645739f.8.1722643073028; Fri, 02 Aug 2024 16:57:53 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke Subject: [PATCH 13/17] bsd-user: target_mprotect: rename prot to target_prot Date: Fri, 2 Aug 2024 17:56:13 -0600 Message-ID: <20240802235617.7971-14-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-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::d2c; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2c.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643130986116600 Content-Type: text/plain; charset="utf-8" Linux-user's target_mprotect uses this convention, so move to it. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/mmap.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index ed8d31a9048..d34075c5c64 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -61,16 +61,16 @@ void mmap_fork_end(int child) } =20 /* NOTE: all the constants are the HOST ones, but addresses are target. */ -int target_mprotect(abi_ulong start, abi_ulong len, int prot) +int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) { abi_ulong end, host_start, host_end, addr; int prot1, ret; =20 qemu_log_mask(CPU_LOG_PAGE, "mprotect: start=3D0x" TARGET_ABI_FMT_lx " len=3D0x" TARGET_ABI_FMT_lx " prot=3D%c%c%c\n", start,= len, - prot & PROT_READ ? 'r' : '-', - prot & PROT_WRITE ? 'w' : '-', - prot & PROT_EXEC ? 'x' : '-'); + target_prot & PROT_READ ? 'r' : '-', + target_prot & PROT_WRITE ? 'w' : '-', + target_prot & PROT_EXEC ? 'x' : '-'); if ((start & ~TARGET_PAGE_MASK) !=3D 0) return -EINVAL; len =3D TARGET_PAGE_ALIGN(len); @@ -78,7 +78,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int p= rot) return -ENOMEM; } end =3D start + len; - prot &=3D PROT_READ | PROT_WRITE | PROT_EXEC; + target_prot &=3D PROT_READ | PROT_WRITE | PROT_EXEC; if (len =3D=3D 0) return 0; =20 @@ -87,7 +87,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int p= rot) host_end =3D HOST_PAGE_ALIGN(end); if (start > host_start) { /* handle host page containing start */ - prot1 =3D prot; + prot1 =3D target_prot; for (addr =3D host_start; addr < start; addr +=3D TARGET_PAGE_SIZE= ) { prot1 |=3D page_get_flags(addr); } @@ -104,7 +104,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int= prot) host_start +=3D qemu_host_page_size; } if (end < host_end) { - prot1 =3D prot; + prot1 =3D target_prot; for (addr =3D end; addr < host_end; addr +=3D TARGET_PAGE_SIZE) { prot1 |=3D page_get_flags(addr); } @@ -117,11 +117,11 @@ int target_mprotect(abi_ulong start, abi_ulong len, i= nt prot) =20 /* handle the pages in the middle */ if (host_start < host_end) { - ret =3D mprotect(g2h_untagged(host_start), host_end - host_start, = prot); + ret =3D mprotect(g2h_untagged(host_start), host_end - host_start, = target_prot); if (ret !=3D 0) goto error; } - page_set_flags(start, start + len - 1, prot | PAGE_VALID); + page_set_flags(start, start + len - 1, target_prot | PAGE_VALID); mmap_unlock(); return 0; error: --=20 2.45.1 From nobody Sun Nov 24 11:59:45 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=1722643191; cv=none; d=zohomail.com; s=zohoarc; b=YRKnjlrDIZhx4q1UArfh7kYG4+zTtqKJpVXjA5QCVIfeEaT7liDsgdxZHpCzCUyDQAYucYHBkUQ2cbztD5ixzvR7UucJ5ecOzBd17GfKvbivV6gJa74NRfyyKthlaNkYTMRnS2ZjHzN6gr2RyXR5nysiy7ahmRLq3lbEE+mYGis= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643191; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hxMMYdUIWV7BpRLm7ZCMIQipXwTZjxzuoSHO0vQ0wkg=; b=mhRXGEVWpfSwXYxdpqUvwyZUzRHe0mAJVp89TnbOvOUZ1YyTvlPTYrAH7vyhxgLLcG0HfwEOYp63cACyd9Qt4st2ygCnkHP3dM8JlDg1luheHgfMDC26f3MDxPMJzZMSGGIwAFXQ9KmzCh7hS0m6sUUP+wAZqUGVezkw9ljsAo8= 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 1722643191848274.2616931600944; Fri, 2 Aug 2024 16:59:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29p-0002Jc-0k; Fri, 02 Aug 2024 19:58: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 1sa29l-00024Q-HP for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:57 -0400 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29j-0004JB-LL for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:57 -0400 Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-81fd1e1d38bso100892439f.1 for ; Fri, 02 Aug 2024 16:57:55 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643074; x=1723247874; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hxMMYdUIWV7BpRLm7ZCMIQipXwTZjxzuoSHO0vQ0wkg=; b=SQ1KV4Ef2K1ALJpMrxtJH8Y+H3hRJa922zdfzx5woN4S9FO+5hwrtqAyVxPKGShxT8 w6iRryQEGYW0wFy3Nk/OSXRMOPfI3xG4LPo0mv9XQPbcd+FZzB3Kzkdbi1g2+Y0815a9 zJ/+xe8Ftl9oc91ZAspktksNIV0K7t8sQLxoe4Xdh5dLhTQ4Jr41cStBTnVmABVNigSt 0nbp090Nd/v82UD4PTZ0WNpemvGi+WNakzc0iW3CqLaFOzxBPks8hDRufR7UWMlkDKps Qsx4hzuSvjQQbU/1hgo9MkCdyzKnqku1UNEp37JpKbVxkFOVtLYiTxRtM5JgE07exOqj FEiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643074; x=1723247874; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hxMMYdUIWV7BpRLm7ZCMIQipXwTZjxzuoSHO0vQ0wkg=; b=VWblmrtNVf0TxG4r3U73Wh/KRguYIJjpeky7H/DWkmEdFm+EcDThKGmES+HukniUUM qu51ADmezY3VPoDdb3wgFdXIZEr8UegP/8eOgHKssPfVTHB3Qlfq3inNCGMFzt10rASW q/hO/dwz/1tZ0WuahdPcD7HVNpV6EGlVZ6Vh4MS16/pXzZEXDfKD+4y9BT8bpmPkvBuw 8FcFBlejlJydujuAaMjhYFLWCGa92ZJgofMTojNyzEUOv/OQfjQf2i0yX38DnPe8Ptcf lTYaNvPLu2S53EO7OvXu8S1PBBFfcSzO6u2kz7Y2TOvZByMYPA9KAXf4C32bsEFAd3fS xo1g== X-Gm-Message-State: AOJu0YxFuiYT1YNsaAlqn3NfBHmuFurgbBWKdFkKqHstv9/PJGb2mhhZ z2OamCD9+4HzxITGATGhpqkn9Oo0WmCf1858PVRlhced+JNegSpFnL/wpJFSKV41mUP7rZl1BFN fPTI= X-Google-Smtp-Source: AGHT+IGOtmJw+WDFJLDwZQOmXBDlkxuSSUI+xcUIY8OIa5mLiv99XnDwXo+CCxGno1/WCschjBcdRg== X-Received: by 2002:a05:6602:641f:b0:7f7:e273:a97d with SMTP id ca18e2360f4ac-81fd437a1d5mr638006239f.9.1722643074290; Fri, 02 Aug 2024 16:57:54 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke Subject: [PATCH 14/17] bsd-user: target_mmap*: change prot to target_prot Date: Fri, 2 Aug 2024 17:56:14 -0600 Message-ID: <20240802235617.7971-15-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-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::d29; envelope-from=imp@bsdimp.com; helo=mail-io1-xd29.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643193164116600 Content-Type: text/plain; charset="utf-8" Adopt the linux-user convention of using target_prot for passed in protections. no functional change. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/mmap.c | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index d34075c5c64..2118972f073 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -152,7 +152,7 @@ error: */ static int mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong end, - int prot, int flags, int fd, abi_ulong offset) + int target_prot, int flags, int fd, abi_ulong offset) { abi_ulong real_end, addr; void *host_start; @@ -170,20 +170,20 @@ static int mmap_frag(abi_ulong real_start, =20 if (prot1 =3D=3D 0) { /* no page was there, so we allocate one. See also above. */ - void *p =3D mmap(host_start, qemu_host_page_size, prot, + void *p =3D mmap(host_start, qemu_host_page_size, target_prot, flags | ((fd !=3D -1) ? MAP_ANON : 0), -1, 0); if (p =3D=3D MAP_FAILED) return -1; - prot1 =3D prot; + prot1 =3D target_prot; } prot1 &=3D PAGE_RWX; =20 - prot_new =3D prot | prot1; + prot_new =3D target_prot | prot1; 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 && - (prot & PROT_WRITE)) + (target_prot & PROT_WRITE)) return -1; =20 /* adjust protection to be able to read */ @@ -367,7 +367,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) } =20 /* NOTE: all the constants are the HOST ones */ -abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, +abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, int flags, int fd, off_t offset) { abi_ulong ret, end, real_start, real_end, retaddr, host_offset, host_l= en; @@ -377,9 +377,9 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, qemu_log("mmap: start=3D0x" TARGET_ABI_FMT_lx " len=3D0x" TARGET_ABI_FMT_lx " prot=3D%c%c%c flags=3D", start, len, - prot & PROT_READ ? 'r' : '-', - prot & PROT_WRITE ? 'w' : '-', - prot & PROT_EXEC ? 'x' : '-'); + target_prot & PROT_READ ? 'r' : '-', + target_prot & PROT_WRITE ? 'w' : '-', + target_prot & PROT_EXEC ? 'x' : '-'); if (flags & MAP_ALIGNMENT_MASK) { qemu_log("MAP_ALIGNED(%u) ", (flags & MAP_ALIGNMENT_MASK) >> MAP_ALIGNMENT_SHIFT); @@ -416,13 +416,14 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int prot, goto fail; } if (flags & MAP_STACK) { - if ((fd !=3D -1) || ((prot & (PROT_READ | PROT_WRITE)) !=3D - (PROT_READ | PROT_WRITE))) { + if (fd !=3D -1 || + ((target_prot & (PROT_READ | PROT_WRITE)) !=3D + (PROT_READ | PROT_WRITE))) { errno =3D EINVAL; goto fail; } } - if ((flags & MAP_GUARD) && (prot !=3D PROT_NONE || fd !=3D -1 || + if ((flags & MAP_GUARD) && (target_prot !=3D PROT_NONE || fd !=3D -1 || offset !=3D 0 || (flags & (MAP_SHARED | MAP_PRIVATE | /* MAP_PREFAULT | */ /* MAP_PREFAULT not in mman.h */ MAP_PREFAULT_READ | MAP_ANON | MAP_STACK)) !=3D 0)) { @@ -512,14 +513,14 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int prot, * especially important if qemu_host_page_size > * qemu_real_host_page_size */ - p =3D mmap(g2h_untagged(start), host_len, prot, + p =3D mmap(g2h_untagged(start), host_len, target_prot, 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'= */ host_start =3D (unsigned long)p; if (fd !=3D -1) { - p =3D mmap(g2h_untagged(start), len, prot, + p =3D mmap(g2h_untagged(start), len, target_prot, flags | MAP_FIXED, fd, host_offset); if (p =3D=3D MAP_FAILED) { munmap(g2h_untagged(start), host_len); @@ -557,11 +558,11 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int prot, * possible while it is a shared mapping */ if ((flags & TARGET_BSD_MAP_FLAGMASK) =3D=3D MAP_SHARED && - (prot & PROT_WRITE)) { + (target_prot & PROT_WRITE)) { errno =3D EINVAL; goto fail; } - retaddr =3D target_mmap(start, len, prot | PROT_WRITE, + retaddr =3D target_mmap(start, len, target_prot | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0); if (retaddr =3D=3D -1) @@ -569,8 +570,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, 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 (!(target_prot & PROT_WRITE)) { + ret =3D target_mprotect(start, len, target_prot); assert(ret =3D=3D 0); } goto the_end; @@ -587,13 +588,13 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int prot, if (real_end =3D=3D real_start + qemu_host_page_size) { /* one single host page */ ret =3D mmap_frag(real_start, start, end, - prot, flags, fd, offset); + target_prot, flags, fd, offset); if (ret =3D=3D -1) goto fail; goto the_end1; } ret =3D mmap_frag(real_start, start, real_start + qemu_host_pa= ge_size, - prot, flags, fd, offset); + target_prot, flags, fd, offset); if (ret =3D=3D -1) goto fail; real_start +=3D qemu_host_page_size; @@ -602,7 +603,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, if (end < real_end) { ret =3D mmap_frag(real_end - qemu_host_page_size, real_end - qemu_host_page_size, end, - prot, flags, fd, + target_prot, flags, fd, offset + real_end - qemu_host_page_size - star= t); if (ret =3D=3D -1) goto fail; @@ -618,13 +619,13 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int prot, else offset1 =3D offset + real_start - start; p =3D mmap(g2h_untagged(real_start), real_end - real_start, - prot, flags, fd, offset1); + target_prot, flags, fd, offset1); if (p =3D=3D MAP_FAILED) goto fail; } } the_end1: - page_set_flags(start, start + len - 1, prot | PAGE_VALID); + page_set_flags(start, start + len - 1, target_prot | PAGE_VALID); the_end: #ifdef DEBUG_MMAP printf("ret=3D0x" TARGET_ABI_FMT_lx "\n", start); --=20 2.45.1 From nobody Sun Nov 24 11:59:45 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=1722643115; cv=none; d=zohomail.com; s=zohoarc; b=UorJRZ9g52PnGP9x4qk9Cyrc2OQSooTTh3D7dp39SX0qzoejWO7D9VYv8ShZgcS/4S3mSYlkt6mUOuD0/+tDmOrEpmu6woAIDntRkAQDSuoBVnozbz0prPXGvMVMASjguLh0dBWQ8SDb96U601S25/IBgCOhU+IC8h6K6CR6kQM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643115; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LSto2JlTblPm7lL32v0n5cXRXHwEk3Eun8OyV2xgFYk=; b=c9zMZPU8zL1h9NYrgsXeFUdYzvDxmIVxmX67Arr1NjcgESE+m0enc6WfPL2GIGmmAje/YltZLQULP+EQwkfN7gAH31DRzJb0nRWSuGST5OylqCr2BvsvP1LD3p0NDpZFJo5BtDqt9cZ7B6N+GfzbRyw4WO7sc/gGiPZCCaKOH50= 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 1722643115761996.1095566482647; Fri, 2 Aug 2024 16:58:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29o-0002Iv-TO; Fri, 02 Aug 2024 19:58:00 -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 1sa29m-0002AM-UA for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:59 -0400 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29l-0004Jg-Bs for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:58 -0400 Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-81f921c40a0so346408939f.0 for ; Fri, 02 Aug 2024 16:57:56 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643076; x=1723247876; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LSto2JlTblPm7lL32v0n5cXRXHwEk3Eun8OyV2xgFYk=; b=M8MHeNzvfF2sOKpKUlIqBAvlluww7MREpGVSzIu1ee92vVlLt6xDxFxR4T0qEEV6ya IsVOTWgNy/QopAbJBB/nXlCoDYY0sF6Yl+lzOq78duZLL6vmqVzuUo6zC85ShcNfd9rc Nj2W417++sPI/d0O7Cn/LrNpa0CcOtBLfiKtyEAMpYy0uuA/bOVRP88q/QKwCJqTGdPw 8DX84wmhTM3Hcb0CX7FJSsFt3HtO4a4xwgJG6FCNNjwu+16GQoW1O7aXBsIk2XQXys1R sSXM1Rx0XcvbKIIv7NklqBgqBJiZPAYCAsp8IPse6xxyOCrsdJFkx9BBz2QbPTkba9eo 8Fnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643076; x=1723247876; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LSto2JlTblPm7lL32v0n5cXRXHwEk3Eun8OyV2xgFYk=; b=rAHh9y731PxYXIAvlA3GDuOCJgRDyIqiRpJQvOIv0eDvYVqwgWAFpksCSdeCll+gcu Xx919PJQYyB5RRn/1Q+4qOfMyVs5doEOsa0VSaIJbVV/8ENEGmnUEknATAQdGkMW02PR zvj86wtTzewdS6hvzDzXe2cWDLwFd7grJuBvXB/bVLUmw6kb15tkaEgO+0PwYY5l2tMr xBH0JSJqYXMrU3Twq5qbAlvziW72/5R7B5crEP/1JC4nk5osv7FrnCrFnX9O70uaRoi4 RoCcvb/lUp8sNk7adbQDiAI1BLUTr0mzOaPhvfdpSrExSjw/N5RUX1S/vfsnhaaBOorh hIiA== X-Gm-Message-State: AOJu0YwdGnBaouB8uypIM2C7nTlFD3qzgi+gha90+Mv8Kvft1nvZH79Z VR2kWhucNN7zhkELcPI5kgo+2G7oIai9xqtoT+fcjhaRaO4J6b2siNXmqDLjtUTB3bRpu0Rs9Ww rmSc= X-Google-Smtp-Source: AGHT+IETbXa+Mp5jDXt73Y3oKpH6ChskQHJZmg8+gfksu4bMm78r8LCx3sJZIP9WjRcX2pnEp4DOIQ== X-Received: by 2002:a05:6602:13d4:b0:7fb:87d6:64b with SMTP id ca18e2360f4ac-81fd4405a91mr605406939f.17.1722643075646; Fri, 02 Aug 2024 16:57:55 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke Subject: [PATCH 15/17] bsd-user: target_mprotect: use helper host_page_size local Date: Fri, 2 Aug 2024 17:56:15 -0600 Message-ID: <20240802235617.7971-16-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-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::d30; envelope-from=imp@bsdimp.com; helo=mail-io1-xd30.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643117342116600 Content-Type: text/plain; charset="utf-8" Use helper variable for host_page_size. Linux-user uses a similar helper to make the code smaller after the multi-page-size migration. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/mmap.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index 2118972f073..ffecf52a72a 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -63,6 +63,7 @@ void mmap_fork_end(int child) /* NOTE: all the constants are the HOST ones, but addresses are target. */ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) { + int host_page_size =3D qemu_real_host_page_size(); abi_ulong end, host_start, host_end, addr; int prot1, ret; =20 @@ -83,7 +84,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int t= arget_prot) return 0; =20 mmap_lock(); - host_start =3D start & qemu_host_page_mask; + host_start =3D start & -host_page_size; host_end =3D HOST_PAGE_ALIGN(end); if (start > host_start) { /* handle host page containing start */ @@ -91,28 +92,28 @@ int target_mprotect(abi_ulong start, abi_ulong len, int= target_prot) for (addr =3D host_start; addr < start; addr +=3D TARGET_PAGE_SIZE= ) { prot1 |=3D page_get_flags(addr); } - if (host_end =3D=3D host_start + qemu_host_page_size) { + if (host_end =3D=3D host_start + host_page_size) { for (addr =3D end; addr < host_end; addr +=3D TARGET_PAGE_SIZE= ) { prot1 |=3D page_get_flags(addr); } end =3D host_end; } ret =3D mprotect(g2h_untagged(host_start), - qemu_host_page_size, prot1 & PAGE_RWX); + host_page_size, prot1 & PAGE_RWX); if (ret !=3D 0) goto error; - host_start +=3D qemu_host_page_size; + host_start +=3D host_page_size; } if (end < host_end) { prot1 =3D target_prot; for (addr =3D end; addr < host_end; addr +=3D TARGET_PAGE_SIZE) { prot1 |=3D page_get_flags(addr); } - ret =3D mprotect(g2h_untagged(host_end - qemu_host_page_size), - qemu_host_page_size, prot1 & PAGE_RWX); + ret =3D mprotect(g2h_untagged(host_end - host_page_size), + host_page_size, prot1 & PAGE_RWX); if (ret !=3D 0) goto error; - host_end -=3D qemu_host_page_size; + host_end -=3D host_page_size; } =20 /* handle the pages in the middle */ --=20 2.45.1 From nobody Sun Nov 24 11:59:45 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=1722643195; cv=none; d=zohomail.com; s=zohoarc; b=Q0cOSVGMs7hNecZ4Uo39dlvRMhLuDteXQPTwFBFHtRgXWSYh1/wmdWqaRbInjCprwk507SmMa/Q/xn5XCpr/pliFCMxH26fDPBJSVtGIgsJ6cxzAL4MCWb8bh3qcoEs0ayVUgeo+x4xIpDOGVeG2ojj56ZsayxmIoxXlMUUSUh4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643195; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=g3kDJhuVOCuA9YqIFpqwx9TDE8LgGOs4efk+QHLf3Y4=; b=hoe1oI/sOU94sbyEMv9Pw6sa2qoI/2t5KAcSvrixs9FgLNEd7o9QtP94HDdcpWmzt524hfpRISlSlTg4IEGZTPerA6CKpSz8PAXZMsZf4/TgtRce/1cmPkIGqX8i8h02wwOSS1yQnuZ88P//FaJDK/FoyRV7Q3SOyHvwib8QLWw= 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 1722643195369113.60050687172622; Fri, 2 Aug 2024 16:59:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29p-0002Le-HP; Fri, 02 Aug 2024 19:58: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 1sa29o-0002Fm-56 for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:58:00 -0400 Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29m-0004Kz-7o for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:59 -0400 Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-81fd520fee5so57865339f.2 for ; Fri, 02 Aug 2024 16:57:57 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643076; x=1723247876; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=g3kDJhuVOCuA9YqIFpqwx9TDE8LgGOs4efk+QHLf3Y4=; b=BE+MpRiwRcM4QOanS7lGaJDEZtqKGsYRIQWOdNm/MFsOfS0BRuo0vj7hqDocFoR/CT LxtP8azy8sBFQY5fPQ/eb8sGWt4BSgGUIfLb6MyRlol/SLdRm+6YxyN4B1xCtso18Dov K8D/Vf0ScqVOJphU76Fag7/iHWY0fRLPTJYYjLXYA9gATbgOIlnh4ye5xZ3vGDywWtq7 EoU2o/T5DEswQOyQTuvr0Xzh1pnSMNztPHN2JceIPxG6A++XjfFxplVFMRStrvg6Ztsm HNHjPhQu0va8oVHsmP5WZYKZqZynRRLc12C4RFXOFCay+PXGSQU9QKNX/lH2vfi9PsK7 9zDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643076; x=1723247876; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g3kDJhuVOCuA9YqIFpqwx9TDE8LgGOs4efk+QHLf3Y4=; b=SiDMu4uJ0uQHYtUc8jb3AGJieEVZEF4V1N20RXE1v5I4sqoxqNct7ktfeBlnzbbZYB XktW9WYhCXJMnrZHTWuljFN74+YPdU3crnqpkTHWrQTKz8PPpJgloLWV5WrR3RZH7+bI 87fyhx1i+TbnWePgmQmreJELnOb+XzfjuWSuro63oVgy2XqwtGoe8DE4ZYEEdOZ48ZVd NFqPjYrYqb7w/1/VX5wmuoiMnPBfttW7KIHbG4ygQBku1VuZrAb6BHF08nxiXBJZqS7h pCOgWBonnRYOcLqcs7cJGRzvQM+Nv/Gn9W2toE1xIoiYFy+GRzYnUuhQef08cF5+82Bu CbGg== X-Gm-Message-State: AOJu0Yy2Y6WlYbEDLoMab25dmDGjvPpTyNp4NgajjPVAIUtSdG/iqBqv T1sPzIRSf1dLJ8GLW5py7egga8QLb8AhOdf10BN0FHD498QtSgDdm60JWQ++vEUWr3+yGTYxcCr DE/M= X-Google-Smtp-Source: AGHT+IELASuw97UAzcir4BinQoP3HvesnqYEnH2VyaF/0j3lz2iudTNLtU7/pPm3syqcaltgUWIGAw== X-Received: by 2002:a05:6602:3fcb:b0:81e:23e8:8d4 with SMTP id ca18e2360f4ac-81fd435b40bmr628481439f.6.1722643076330; Fri, 02 Aug 2024 16:57:56 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke Subject: [PATCH 16/17] bsd-user: Define validate_prot_to_pageflags and use in mprotect Date: Fri, 2 Aug 2024 17:56:16 -0600 Message-ID: <20240802235617.7971-17-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-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::d2c; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2c.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643197150116600 Content-Type: text/plain; charset="utf-8" Define validate_prot_to_pageflags. Use it in target_mprotect to validate the flags. Our taraget_mmap needs more work before it can be used there, do don't copy linux-user's use of it there. This should hvae no net functional change, but does make target_mprotect more similar to linux-user's. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/mmap.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index ffecf52a72a..3c48a188e88 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -60,12 +60,26 @@ void mmap_fork_end(int child) pthread_mutex_unlock(&mmap_mutex); } =20 +/* + * Validate target prot bitmask. + * Return the prot bitmask for the host in *HOST_PROT. + * Return 0 if the target prot bitmask is invalid, otherwise + * the internal qemu page_flags (which will include PAGE_VALID). + */ +static int validate_prot_to_pageflags(int prot) +{ + int valid =3D PROT_READ | PROT_WRITE | PROT_EXEC; + int page_flags =3D (prot & PAGE_RWX) | PAGE_VALID; + + return prot & ~valid ? 0 : page_flags; +} + /* NOTE: all the constants are the HOST ones, but addresses are target. */ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) { int host_page_size =3D qemu_real_host_page_size(); abi_ulong end, host_start, host_end, addr; - int prot1, ret; + int prot1, ret, page_flags; =20 qemu_log_mask(CPU_LOG_PAGE, "mprotect: start=3D0x" TARGET_ABI_FMT_lx " len=3D0x" TARGET_ABI_FMT_lx " prot=3D%c%c%c\n", start,= len, @@ -74,14 +88,18 @@ int target_mprotect(abi_ulong start, abi_ulong len, int= target_prot) target_prot & PROT_EXEC ? 'x' : '-'); if ((start & ~TARGET_PAGE_MASK) !=3D 0) return -EINVAL; + page_flags =3D validate_prot_to_pageflags(target_prot); + if (!page_flags) { + return -TARGET_EINVAL; + } len =3D TARGET_PAGE_ALIGN(len); + if (len =3D=3D 0) + return 0; if (!guest_range_valid_untagged(start, len)) { return -ENOMEM; } - end =3D start + len; target_prot &=3D PROT_READ | PROT_WRITE | PROT_EXEC; - if (len =3D=3D 0) - return 0; + end =3D start + len; =20 mmap_lock(); host_start =3D start & -host_page_size; @@ -122,7 +140,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int= target_prot) if (ret !=3D 0) goto error; } - page_set_flags(start, start + len - 1, target_prot | PAGE_VALID); + page_set_flags(start, start + len - 1, page_flags); mmap_unlock(); return 0; error: --=20 2.45.1 From nobody Sun Nov 24 11:59:45 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=1722643165; cv=none; d=zohomail.com; s=zohoarc; b=WRPL0scb5V0ZykR2z3DSITHIe5zKX+blXoeNLNo5BPQoIRErVl856Jhaw1aYCYkeLv7+Lwv0oZ76Y+Cg8uTN6k3608DikFQicpI/byOF47XkRrFB5aW5ZJEe7TIOoPo5tzhxCIkfXJouF8lxoSL5dMR0x/KgGONhRcbu/h7WQVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643165; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=38kVVXcpRVzigthSDk6irqa7cPAYSjq2c74UEfJaIlc=; b=E31cDV00JwB+6IDQBXscT1c/mUGY2cWZuanEGym2fh11pi8NiGQ9aB2jOz2vLMiUU/boL2/EcZXxKHpjUIpViokKCRihZ7Odj6xqnVO6gMp73mpyvi9CPi1MzHDqgR9+QlQmMlIUuBDK4zpRL2jdfo3jmSB+5l5JGBknK/N5Qu8= 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 1722643165657861.570959355446; Fri, 2 Aug 2024 16:59:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29p-0002NC-Uh; Fri, 02 Aug 2024 19:58: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 1sa29o-0002Hh-I5 for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:58:00 -0400 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29m-0004L2-IV for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:58:00 -0400 Received: by mail-io1-xd2f.google.com with SMTP id ca18e2360f4ac-81f86fd93acso128172139f.1 for ; Fri, 02 Aug 2024 16:57:58 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643077; x=1723247877; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=38kVVXcpRVzigthSDk6irqa7cPAYSjq2c74UEfJaIlc=; b=NMvE/plYa7VzJNbc05CY0RaLBgBEz/JUxsswjNBfjsjKZBpuZj1su7ZYmf6M8uqr3V kccUIp7VtWkgFF71RoW/k6Suf0SnKxqZJXqt2QIEn6/FXdzLS+WGqEw40ltvt67VBlWU EodepFdJQ7kTezBLERpRKrauwoNCtYsS49rYSZKVQnGViUHQxc063EET17NQv9wWS1Q6 eyrYLaD1ihRA/I1utSoERbj9dcrep3FgQmMcnXvqsFULNQTFVYnpfGH1zOhLmaIajIO4 J8PHiHD+4/Nv3JhHL2nMVaedyQsc7FRb3F7GR9xl75UXtDDPP4UI6W/Q5/O9w9fjhVQN rE9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643077; x=1723247877; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=38kVVXcpRVzigthSDk6irqa7cPAYSjq2c74UEfJaIlc=; b=OX0rFyBNWE7yBrw1JLnwzwPbyGoJJURtmoyPKGqTpaVMK12HI5AkamX0YxIFN2SLjo 3FwAB1UyeMKrVZ7DfO5NjGG18YLPryZ6VPiqsQiMu+52pSKVIurq9bcQvYObdDYxqfu/ lnhD8pWyB5qaN3vT00obXSZdAkfj71TZm87nYniZSSS76CV444IA4ZHeNoF2GeAeR5AD u73Xr05GkX05Asn2ARWhX2aLFGt2JVIPML/ZxJJe579PUu4GNFqTRWwGLdJwQPehWSrH jWkK2Fygat2jgcErwzZQwQq+JPscz18QmN0L1Pm4d8mj32KmC4BwN8hmZCCUTaOmHfT1 d/DQ== X-Gm-Message-State: AOJu0YwyPiSbplOKALAqORjAgC6V9iIRi5E5FfMSUUlpSL61x2Xvf475 u18xFehUT+MsbDPxtbIz7bu/fz/EyvZUoLFT+t/Cv4c+dC527V6HH9A1nhnlub66GbjIy8kxmL7 YmV0= X-Google-Smtp-Source: AGHT+IFvfUBT+yr8mGnwlmG+vqVkKBTVuNRMPnfbSTRxMJG4HDzlJLXnTTGXpe52XCOXffW01XD/wg== X-Received: by 2002:a5d:8e19:0:b0:806:3dac:5081 with SMTP id ca18e2360f4ac-81fd11321aemr415677139f.7.1722643077036; Fri, 02 Aug 2024 16:57:57 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke Subject: [PATCH 17/17] bsd-user: copy linux-user target_mprotect impl Date: Fri, 2 Aug 2024 17:56:17 -0600 Message-ID: <20240802235617.7971-18-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643167102116600 Content-Type: text/plain; charset="utf-8" Now that we're closer to the linux-user target_mprotect code, go ahead and grab the rest of the implementation. This moves from a stard, end impl to a start, last which will allow last page mapping, etc. This also moves to a more general algorithm. We're close enough that this jump isn't so large, and doing it incrementally further has become too much work for too little gain. Signed-off-by: Warner Losh Acked-by: Richard Henderson --- bsd-user/mmap.c | 138 +++++++++++++++++++++++++++++++----------------- 1 file changed, 90 insertions(+), 48 deletions(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index 3c48a188e88..a4de7674bec 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -60,6 +60,17 @@ void mmap_fork_end(int child) pthread_mutex_unlock(&mmap_mutex); } =20 +/* + * Map target protection mask to host. Identity on FreeBSD. + */ +static abi_ulong target_to_host_prot(abi_ulong prot) +{ + return (prot); +} + +/* Helpful temporary #define to reduce diffs with linux-user mmap.c */ +#define trace_target_mprotect(start, len, target_prot) + /* * Validate target prot bitmask. * Return the prot bitmask for the host in *HOST_PROT. @@ -78,72 +89,103 @@ static int validate_prot_to_pageflags(int prot) int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) { int host_page_size =3D qemu_real_host_page_size(); - abi_ulong end, host_start, host_end, addr; - int prot1, ret, page_flags; - - qemu_log_mask(CPU_LOG_PAGE, "mprotect: start=3D0x" TARGET_ABI_FMT_lx - " len=3D0x" TARGET_ABI_FMT_lx " prot=3D%c%c%c\n", start,= len, - target_prot & PROT_READ ? 'r' : '-', - target_prot & PROT_WRITE ? 'w' : '-', - target_prot & PROT_EXEC ? 'x' : '-'); - if ((start & ~TARGET_PAGE_MASK) !=3D 0) - return -EINVAL; + abi_ulong starts[3]; + abi_ulong lens[3]; + int prots[3]; + abi_ulong host_start, host_last, last; + int prot1, ret, page_flags, nranges; + + trace_target_mprotect(start, len, target_prot); + + if ((start & ~TARGET_PAGE_MASK) !=3D 0) { + return -TARGET_EINVAL; + } page_flags =3D validate_prot_to_pageflags(target_prot); if (!page_flags) { return -TARGET_EINVAL; } - len =3D TARGET_PAGE_ALIGN(len); - if (len =3D=3D 0) + if (len =3D=3D 0) { return 0; + } + len =3D TARGET_PAGE_ALIGN(len); if (!guest_range_valid_untagged(start, len)) { - return -ENOMEM; + return -TARGET_ENOMEM; } - target_prot &=3D PROT_READ | PROT_WRITE | PROT_EXEC; - end =3D start + len; =20 - mmap_lock(); + last =3D start + len - 1; host_start =3D start & -host_page_size; - host_end =3D HOST_PAGE_ALIGN(end); - if (start > host_start) { - /* handle host page containing start */ + host_last =3D ROUND_UP(last, host_page_size) - 1; + nranges =3D 0; + + mmap_lock(); + + if (host_last - host_start < host_page_size) { + /* Single host page contains all guest pages: sum the prot. */ prot1 =3D target_prot; - for (addr =3D host_start; addr < start; addr +=3D TARGET_PAGE_SIZE= ) { - prot1 |=3D page_get_flags(addr); + for (abi_ulong a =3D host_start; a < start; a +=3D TARGET_PAGE_SIZ= E) { + prot1 |=3D page_get_flags(a); + } + for (abi_ulong a =3D last; a < host_last; a +=3D TARGET_PAGE_SIZE)= { + prot1 |=3D page_get_flags(a + 1); } - if (host_end =3D=3D host_start + host_page_size) { - for (addr =3D end; addr < host_end; addr +=3D TARGET_PAGE_SIZE= ) { - prot1 |=3D page_get_flags(addr); + starts[nranges] =3D host_start; + lens[nranges] =3D host_page_size; + prots[nranges] =3D prot1; + nranges++; + } else { + if (host_start < start) { + /* Host page contains more than one guest page: sum the prot. = */ + prot1 =3D target_prot; + for (abi_ulong a =3D host_start; a < start; a +=3D TARGET_PAGE= _SIZE) { + prot1 |=3D page_get_flags(a); + } + /* If the resulting sum differs, create a new range. */ + if (prot1 !=3D target_prot) { + starts[nranges] =3D host_start; + lens[nranges] =3D host_page_size; + prots[nranges] =3D prot1; + nranges++; + host_start +=3D host_page_size; } - end =3D host_end; } - ret =3D mprotect(g2h_untagged(host_start), - host_page_size, prot1 & PAGE_RWX); - if (ret !=3D 0) - goto error; - host_start +=3D host_page_size; - } - if (end < host_end) { - prot1 =3D target_prot; - for (addr =3D end; addr < host_end; addr +=3D TARGET_PAGE_SIZE) { - prot1 |=3D page_get_flags(addr); + + if (last < host_last) { + /* Host page contains more than one guest page: sum the prot. = */ + prot1 =3D target_prot; + for (abi_ulong a =3D last; a < host_last; a +=3D TARGET_PAGE_S= IZE) { + prot1 |=3D page_get_flags(a + 1); + } + /* If the resulting sum differs, create a new range. */ + if (prot1 !=3D target_prot) { + host_last -=3D host_page_size; + starts[nranges] =3D host_last + 1; + lens[nranges] =3D host_page_size; + prots[nranges] =3D prot1; + nranges++; + } + } + + /* Create a range for the middle, if any remains. */ + if (host_start < host_last) { + starts[nranges] =3D host_start; + lens[nranges] =3D host_last - host_start + 1; + prots[nranges] =3D target_prot; + nranges++; } - ret =3D mprotect(g2h_untagged(host_end - host_page_size), - host_page_size, prot1 & PAGE_RWX); - if (ret !=3D 0) - goto error; - host_end -=3D host_page_size; } =20 - /* handle the pages in the middle */ - if (host_start < host_end) { - ret =3D mprotect(g2h_untagged(host_start), host_end - host_start, = target_prot); - if (ret !=3D 0) + for (int i =3D 0; i < nranges; ++i) { + ret =3D mprotect(g2h_untagged(starts[i]), lens[i], + target_to_host_prot(prots[i])); + if (ret !=3D 0) { goto error; + } } - page_set_flags(start, start + len - 1, page_flags); - mmap_unlock(); - return 0; -error: + + page_set_flags(start, last, page_flags); + ret =3D 0; + + error: mmap_unlock(); return ret; } --=20 2.45.1