From nobody Sun Nov 24 13:43:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=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