From nobody Wed May 22 03:22:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1662423082; cv=none; d=zohomail.com; s=zohoarc; b=mHU6c0JG9r9XH6xiHMc3m/Yov+tEbGh4VwJJEfrcr2PHq5SfQer6OFR4rVBkV1HmlGp8von+cAZO4AkW5FWplvD+XLTIk+f79e0PdGqToslqAl233J7NErHJ+C18LQYUKyAirp6fWgGE9NdIBLdUBCJkYqv6G5yfA0nF7zctp7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662423082; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=f+NjNWnUkwsuzU4eJD/wtK4cLCNeciA0GFbsOrawchc=; b=HWOkK+9/I8B/NWzxR9fyCCubY5P2NeP8bA+aLauYtFlK4By+v/aTORgRj9Hpm6H6Jc9P03xYOx8Z65n/w6OlAKJKTkj+OvZY5ThJgk5Mvgl1o0USYWSaqloRLIQHaT2IHHe0cTZh8bJhGx+nEqs/C7hNC0nWftss1vRSLP4zoKI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1662423082250841.8047847900667; Mon, 5 Sep 2022 17:11:22 -0700 (PDT) Received: from localhost ([::1]:56810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVMBU-0005lt-TX for importer@patchew.org; Mon, 05 Sep 2022 20:11:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVM9P-0003qF-B4 for qemu-devel@nongnu.org; Mon, 05 Sep 2022 20:09:11 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:31346) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVM9B-0002HD-60 for qemu-devel@nongnu.org; Mon, 05 Sep 2022 20:09:08 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 285NqwcI026813; Tue, 6 Sep 2022 00:08:55 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jdu60rf1r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 00:08:55 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 285NspT9003250; Tue, 6 Sep 2022 00:08:54 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jdu60rf0e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 00:08:54 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 286067DQ024914; Tue, 6 Sep 2022 00:08:52 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma04ams.nl.ibm.com with ESMTP id 3jbxj8u00r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 00:08:52 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28605MxU24379686 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 6 Sep 2022 00:05:22 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C780711C050; Tue, 6 Sep 2022 00:08:49 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 68A2311C04C; Tue, 6 Sep 2022 00:08:49 +0000 (GMT) Received: from heavy.lan (unknown [9.171.53.58]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 6 Sep 2022 00:08:49 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=f+NjNWnUkwsuzU4eJD/wtK4cLCNeciA0GFbsOrawchc=; b=HEqstNKz/nQwHqfp1ph5eVp8Z5JHIruvvCUXMrGmXnX3l9QBsJLO5nx2teHl0igSZ2gJ TkXhxlLSF94wjhzL/ShlPF7/7Ch0njKt+LNq+jOPKkZ3uLGqTn3vtnYhzWgPX8SelT+s cFa6kxnwxZ0/3FDwtqSxctKDgjnihIaDqK/NpsCE4JL0thIxmZNVVjUvY8MLMM/i/5A/ DWARGgjLPdAm+dG2l7fqRykNhDDaWXNTMURNzpZfjTp0R/R/nYSIqlfBlNFSPJZkwQSC 19CQtaqKORUzcliqIErh3mttlEUvER7wjJLXfA1Xfvy5ctaXpgQy/IYxO/WQoUo0aVXz Ag== From: Ilya Leoshkevich To: Richard Henderson , Paolo Bonzini , Laurent Vivier , Taylor Simpson , =?UTF-8?q?Alex=20Benn=C3=A9e?= Cc: qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH v3 1/5] linux-user: Provide MADV_* definitions Date: Tue, 6 Sep 2022 02:08:35 +0200 Message-Id: <20220906000839.1672934-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220906000839.1672934-1-iii@linux.ibm.com> References: <20220906000839.1672934-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: zAimjCC2z69aplzyO0OPb6fokVu2P3iT X-Proofpoint-ORIG-GUID: eQoJz3lbrgCJ3RW5REE_ra3J0SD15sG2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-05_16,2022-09-05_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxlogscore=741 suspectscore=0 bulkscore=0 priorityscore=1501 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 adultscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209050118 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1662423083841100001 Content-Type: text/plain; charset="utf-8" Provide MADV_* definitions using target_mman.h header, similar to what kernel does. Most architectures use the same values, with the exception of alpha and hppa. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson --- linux-user/aarch64/target_mman.h | 1 + linux-user/alpha/target_mman.h | 8 +++ linux-user/arm/target_mman.h | 1 + linux-user/cris/target_mman.h | 1 + linux-user/generic/target_mman.h | 92 ++++++++++++++++++++++++++++ linux-user/hexagon/target_mman.h | 1 + linux-user/hppa/target_mman.h | 15 +++++ linux-user/i386/target_mman.h | 1 + linux-user/loongarch64/target_mman.h | 1 + linux-user/m68k/target_mman.h | 1 + linux-user/microblaze/target_mman.h | 1 + linux-user/mips/target_mman.h | 1 + linux-user/mips64/target_mman.h | 1 + linux-user/nios2/target_mman.h | 1 + linux-user/openrisc/target_mman.h | 1 + linux-user/ppc/target_mman.h | 1 + linux-user/riscv/target_mman.h | 1 + linux-user/s390x/target_mman.h | 1 + linux-user/sh4/target_mman.h | 1 + linux-user/sparc/target_mman.h | 1 + linux-user/x86_64/target_mman.h | 1 + linux-user/xtensa/target_mman.h | 1 + 22 files changed, 134 insertions(+) create mode 100644 linux-user/aarch64/target_mman.h create mode 100644 linux-user/alpha/target_mman.h create mode 100644 linux-user/arm/target_mman.h create mode 100644 linux-user/cris/target_mman.h create mode 100644 linux-user/generic/target_mman.h create mode 100644 linux-user/hexagon/target_mman.h create mode 100644 linux-user/hppa/target_mman.h create mode 100644 linux-user/i386/target_mman.h create mode 100644 linux-user/loongarch64/target_mman.h create mode 100644 linux-user/m68k/target_mman.h create mode 100644 linux-user/microblaze/target_mman.h create mode 100644 linux-user/mips/target_mman.h create mode 100644 linux-user/mips64/target_mman.h create mode 100644 linux-user/nios2/target_mman.h create mode 100644 linux-user/openrisc/target_mman.h create mode 100644 linux-user/ppc/target_mman.h create mode 100644 linux-user/riscv/target_mman.h create mode 100644 linux-user/s390x/target_mman.h create mode 100644 linux-user/sh4/target_mman.h create mode 100644 linux-user/sparc/target_mman.h create mode 100644 linux-user/x86_64/target_mman.h create mode 100644 linux-user/xtensa/target_mman.h diff --git a/linux-user/aarch64/target_mman.h b/linux-user/aarch64/target_m= man.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/aarch64/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/alpha/target_mman.h b/linux-user/alpha/target_mman.h new file mode 100644 index 0000000000..cd6e3d70a6 --- /dev/null +++ b/linux-user/alpha/target_mman.h @@ -0,0 +1,8 @@ +#ifndef ALPHA_TARGET_MMAN_H +#define ALPHA_TARGET_MMAN_H + +#define TARGET_MADV_DONTNEED 6 + +#include "../generic/target_mman.h" + +#endif diff --git a/linux-user/arm/target_mman.h b/linux-user/arm/target_mman.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/arm/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/cris/target_mman.h b/linux-user/cris/target_mman.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/cris/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/generic/target_mman.h b/linux-user/generic/target_m= man.h new file mode 100644 index 0000000000..1436a3c543 --- /dev/null +++ b/linux-user/generic/target_mman.h @@ -0,0 +1,92 @@ +#ifndef LINUX_USER_TARGET_MMAN_H +#define LINUX_USER_TARGET_MMAN_H + +#ifndef TARGET_MADV_NORMAL +#define TARGET_MADV_NORMAL 0 +#endif + +#ifndef TARGET_MADV_RANDOM +#define TARGET_MADV_RANDOM 1 +#endif + +#ifndef TARGET_MADV_SEQUENTIAL +#define TARGET_MADV_SEQUENTIAL 2 +#endif + +#ifndef TARGET_MADV_WILLNEED +#define TARGET_MADV_WILLNEED 3 +#endif + +#ifndef TARGET_MADV_DONTNEED +#define TARGET_MADV_DONTNEED 4 +#endif + +#ifndef TARGET_MADV_FREE +#define TARGET_MADV_FREE 8 +#endif + +#ifndef TARGET_MADV_REMOVE +#define TARGET_MADV_REMOVE 9 +#endif + +#ifndef TARGET_MADV_DONTFORK +#define TARGET_MADV_DONTFORK 10 +#endif + +#ifndef TARGET_MADV_DOFORK +#define TARGET_MADV_DOFORK 11 +#endif + +#ifndef TARGET_MADV_MERGEABLE +#define TARGET_MADV_MERGEABLE 12 +#endif + +#ifndef TARGET_MADV_UNMERGEABLE +#define TARGET_MADV_UNMERGEABLE 13 +#endif + +#ifndef TARGET_MADV_HUGEPAGE +#define TARGET_MADV_HUGEPAGE 14 +#endif + +#ifndef TARGET_MADV_NOHUGEPAGE +#define TARGET_MADV_NOHUGEPAGE 15 +#endif + +#ifndef TARGET_MADV_DONTDUMP +#define TARGET_MADV_DONTDUMP 16 +#endif + +#ifndef TARGET_MADV_DODUMP +#define TARGET_MADV_DODUMP 17 +#endif + +#ifndef TARGET_MADV_WIPEONFORK +#define TARGET_MADV_WIPEONFORK 18 +#endif + +#ifndef TARGET_MADV_KEEPONFORK +#define TARGET_MADV_KEEPONFORK 19 +#endif + +#ifndef TARGET_MADV_COLD +#define TARGET_MADV_COLD 20 +#endif + +#ifndef TARGET_MADV_PAGEOUT +#define TARGET_MADV_PAGEOUT 21 +#endif + +#ifndef TARGET_MADV_POPULATE_READ +#define TARGET_MADV_POPULATE_READ 22 +#endif + +#ifndef TARGET_MADV_POPULATE_WRITE +#define TARGET_MADV_POPULATE_WRITE 23 +#endif + +#ifndef TARGET_MADV_DONTNEED_LOCKED +#define TARGET_MADV_DONTNEED_LOCKED 24 +#endif + +#endif diff --git a/linux-user/hexagon/target_mman.h b/linux-user/hexagon/target_m= man.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/hexagon/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/hppa/target_mman.h b/linux-user/hppa/target_mman.h new file mode 100644 index 0000000000..66dd9f7941 --- /dev/null +++ b/linux-user/hppa/target_mman.h @@ -0,0 +1,15 @@ +#ifndef HPPA_TARGET_MMAN_H +#define HPPA_TARGET_MMAN_H + +#define TARGET_MADV_MERGEABLE 65 +#define TARGET_MADV_UNMERGEABLE 66 +#define TARGET_MADV_HUGEPAGE 67 +#define TARGET_MADV_NOHUGEPAGE 68 +#define TARGET_MADV_DONTDUMP 69 +#define TARGET_MADV_DODUMP 70 +#define TARGET_MADV_WIPEONFORK 71 +#define TARGET_MADV_KEEPONFORK 72 + +#include "../generic/target_mman.h" + +#endif diff --git a/linux-user/i386/target_mman.h b/linux-user/i386/target_mman.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/i386/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/loongarch64/target_mman.h b/linux-user/loongarch64/= target_mman.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/loongarch64/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/m68k/target_mman.h b/linux-user/m68k/target_mman.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/m68k/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/microblaze/target_mman.h b/linux-user/microblaze/ta= rget_mman.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/microblaze/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/mips/target_mman.h b/linux-user/mips/target_mman.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/mips/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/mips64/target_mman.h b/linux-user/mips64/target_mma= n.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/mips64/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/nios2/target_mman.h b/linux-user/nios2/target_mman.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/nios2/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/openrisc/target_mman.h b/linux-user/openrisc/target= _mman.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/openrisc/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/ppc/target_mman.h b/linux-user/ppc/target_mman.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/ppc/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/riscv/target_mman.h b/linux-user/riscv/target_mman.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/riscv/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/s390x/target_mman.h b/linux-user/s390x/target_mman.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/s390x/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/sh4/target_mman.h b/linux-user/sh4/target_mman.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/sh4/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/sparc/target_mman.h b/linux-user/sparc/target_mman.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/sparc/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/x86_64/target_mman.h b/linux-user/x86_64/target_mma= n.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/x86_64/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" diff --git a/linux-user/xtensa/target_mman.h b/linux-user/xtensa/target_mma= n.h new file mode 100644 index 0000000000..e7ba6070fe --- /dev/null +++ b/linux-user/xtensa/target_mman.h @@ -0,0 +1 @@ +#include "../generic/target_mman.h" --=20 2.37.2 From nobody Wed May 22 03:22:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1662423245; cv=none; d=zohomail.com; s=zohoarc; b=fRE+YBjDf9bAi1yE0dDNy52b7G/MMh9+rGMgP4W2vU6QGhyC2SoIda5mHPGJyarlsMtbF0dApg1IhQcqT+AI6ds+S2HQKBEzg/vonIbkjq/b1b/pfKOhMnTOp1VhHEwnL78adXiOFtQsnYnOmoB9B85ca4V0UGd8bZMUy/BI1dk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662423245; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Qw294nry3VonO7lIiHmYMewAg6tBtFHgQRGebHXyqyQ=; b=CMAgzBEkTgvoKIGi9X9ldWwvbNNgxBQMY4gBPMXUHmXCOVJnTOf0M6qcS3JMASvTbwoXMcLdNTRyeo2yFxK+fgf60+gWThVkAd5BzWdUK6QOlJvexeb3Gcabiou/oQSjrO7b1Nqg/JRw2dC3QGY36E0ba8/5Uh1NerG+jN5og7w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1662423245292510.2360015195783; Mon, 5 Sep 2022 17:14:05 -0700 (PDT) Received: from localhost ([::1]:49902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVME8-0001Ui-Ao for importer@patchew.org; Mon, 05 Sep 2022 20:14:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVM9Q-0003sW-Jp for qemu-devel@nongnu.org; Mon, 05 Sep 2022 20:09:12 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:64124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVM9M-0002Hl-4k for qemu-devel@nongnu.org; Mon, 05 Sep 2022 20:09:12 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 285Nqd3g025412; Tue, 6 Sep 2022 00:09:05 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jdu60rf8g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 00:09:05 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 285NspTB003250; Tue, 6 Sep 2022 00:09:04 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jdu60rf6p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 00:09:04 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 286065Gi010327; Tue, 6 Sep 2022 00:09:02 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03ams.nl.ibm.com with ESMTP id 3jbxj8u0xm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 00:09:01 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28608vGs41156988 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 6 Sep 2022 00:08:57 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C159011C04C; Tue, 6 Sep 2022 00:08:57 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 594F511C04A; Tue, 6 Sep 2022 00:08:57 +0000 (GMT) Received: from heavy.lan (unknown [9.171.53.58]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 6 Sep 2022 00:08:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=Qw294nry3VonO7lIiHmYMewAg6tBtFHgQRGebHXyqyQ=; b=sVLhztYuHLHsFr1s31FMbZYqYMoyXHjoC2r694M6pBUA3YSvWHhrj8iugWZu7LBwDzO8 jkXjMZSzp1D8MLLkmb9Ajs9gDT1PWjMEmWIW7FiSgGiXondkxu49QTwkwP1nm2U/NYmO R7BDDTYE+Jaq9auQQ6oTF+8kd+Xr8YMQcWW7seE0z0WXxQh757Xt5KeBn80T0nlXAB0G /OgRXWejXd3+7w3cZ0pu1PleIu/pC/0+ra4/8N3IpL1BRMKrzFLr6WHbxQGP2L5Ho8dg IYAKTiSetRAHm4ur2WYKqUkCLd4cvkQ5ytJvhzhfstLBy3lFFC64v45KIZxjIGlzC2Dy cA== From: Ilya Leoshkevich To: Richard Henderson , Paolo Bonzini , Laurent Vivier , Taylor Simpson , =?UTF-8?q?Alex=20Benn=C3=A9e?= Cc: qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH v3 2/5] linux-user: Fix madvise(MADV_DONTNEED) on alpha Date: Tue, 6 Sep 2022 02:08:36 +0200 Message-Id: <20220906000839.1672934-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220906000839.1672934-1-iii@linux.ibm.com> References: <20220906000839.1672934-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: wvgIJgx3ooWKtsn57QT5AGBlNlaqYn8B X-Proofpoint-ORIG-GUID: voPcuxCJmVSh8SDjDvd6Xy3ruQKQtWKH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-05_16,2022-09-05_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxlogscore=990 suspectscore=0 bulkscore=0 priorityscore=1501 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 adultscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209050118 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1662423246687100001 Content-Type: text/plain; charset="utf-8" MADV_DONTNEED has a different value on alpha, compared to all the other architectures. Fix by using TARGET_MADV_DONTNEED instead of MADV_DONTNEED. Fixes: 892a4f6a750a ("linux-user: Add partial support for MADV_DONTNEED") Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson --- linux-user/mmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 048c4135af..a5f1ab129c 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -22,6 +22,7 @@ #include "qemu.h" #include "user-internals.h" #include "user-mmap.h" +#include "target_mman.h" =20 static pthread_mutex_t mmap_mutex =3D PTHREAD_MUTEX_INITIALIZER; static __thread int mmap_lock_count; @@ -891,7 +892,7 @@ abi_long target_madvise(abi_ulong start, abi_ulong len_= in, int advice) * anonymous mappings. In this case passthrough is safe, so do it. */ mmap_lock(); - if (advice =3D=3D MADV_DONTNEED && + if (advice =3D=3D TARGET_MADV_DONTNEED && can_passthrough_madv_dontneed(start, end)) { ret =3D get_errno(madvise(g2h_untagged(start), len, MADV_DONTNEED)= ); if (ret =3D=3D 0) { --=20 2.37.2 From nobody Wed May 22 03:22:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1662423363; cv=none; d=zohomail.com; s=zohoarc; b=VTHND0DOKAolaS1sWT9IsIVMp8G1+ULPdPmE8f8puTRtibOf4uJhUon1PB33HDtk/YHddV/DMk/mbkhUgx48AmRfJtJvCMFhQ7+b9goioWCNP3EFNSm98+voqdJT/KPtO4CQasvx1fwDeywGz9LJbfgVCdfPB5nbp7f5i49eM94= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662423363; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tKrQgj6zNZT8me1fqWZ73d/N0frMlc0M3K02/yCwFLc=; b=H2yRrgqvwz1S7HVCdpRvBUp1nrUuAX1mTx1p1pPbY2Smb+Jx428VSFj5kQH7M1KlqzLLb3H+93dyg1ttNMttUWlpMKnceXStmi+vSiMkuoiBgqRyJ+LXGOrUNKUW3Ke+lxW6UPniTuwTfj3kZcoRSU04pzlO4T7TBWvPERkuFjw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1662423363062363.8297140126814; Mon, 5 Sep 2022 17:16:03 -0700 (PDT) Received: from localhost ([::1]:51220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVMG2-00033L-4m for importer@patchew.org; Mon, 05 Sep 2022 20:16:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVM9Q-0003tD-Mu for qemu-devel@nongnu.org; Mon, 05 Sep 2022 20:09:12 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:20240) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVM9P-0002J2-0D for qemu-devel@nongnu.org; Mon, 05 Sep 2022 20:09:12 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 285MlvYm021146; Tue, 6 Sep 2022 00:09:08 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jdt7n1q51-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 00:09:08 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 285NrRwg010292; Tue, 6 Sep 2022 00:09:08 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jdt7n1q34-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 00:09:08 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 286066WK010328; Tue, 6 Sep 2022 00:09:04 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03ams.nl.ibm.com with ESMTP id 3jbxj8u0xp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 00:09:04 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28609Q3q42402138 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 6 Sep 2022 00:09:26 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9637911C050; Tue, 6 Sep 2022 00:09:02 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 38B5611C04A; Tue, 6 Sep 2022 00:09:02 +0000 (GMT) Received: from heavy.lan (unknown [9.171.53.58]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 6 Sep 2022 00:09:02 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=tKrQgj6zNZT8me1fqWZ73d/N0frMlc0M3K02/yCwFLc=; b=Vgv2Ijua+7RF3Vz8KZwXJ09NV62Fs52r17vDDpTAcY1JEoeLW5nm+6t21L6vZpUQQCeM YXrcorUsz9GcKEhsp+h4dC+WZTgRW3nywi29HPVoJ7fKpZPTRWqQMoHGmyLmiZEiBlN1 +8euvSjkhrEHxguePwj88Fz9vaYWlJG9xPVPeFokrMAMA21KFMEAe054dmERS2Nedxd7 qdrW5PpKntJMBtI/3YY5fOkYWSFrPHJfAZuLu31//TiYmnG99TmBRD3vfQYNbS5o2Ge6 3EACD1w6yQgjwNCG/I8hgsnqrH8XZVdMyV43tt0zmsoI1UpQKOO2IfeHk16vzYRvOYWd hQ== From: Ilya Leoshkevich To: Richard Henderson , Paolo Bonzini , Laurent Vivier , Taylor Simpson , =?UTF-8?q?Alex=20Benn=C3=A9e?= Cc: qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH v3 3/5] linux-user: Implement stracing madvise() Date: Tue, 6 Sep 2022 02:08:37 +0200 Message-Id: <20220906000839.1672934-4-iii@linux.ibm.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220906000839.1672934-1-iii@linux.ibm.com> References: <20220906000839.1672934-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 76VIzvxZP-23bsZ64TnQ5U8X92pXU3C_ X-Proofpoint-ORIG-GUID: 61B0M-TIaSwtDEJOD4P28AC6_SIh6_Pt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-05_16,2022-09-05_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 impostorscore=0 clxscore=1015 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209050118 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1662423364079100001 Content-Type: text/plain; charset="utf-8" The default implementation has several problems: the first argument is not displayed as a pointer, making it harder to grep; the third argument is not symbolized; and there are several extra unused arguments. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson --- linux-user/strace.c | 41 +++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 7d882526da..c262c0c9b6 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -17,6 +17,7 @@ #include "qemu.h" #include "user-internals.h" #include "strace.h" +#include "target_mman.h" =20 struct syscallname { int nr; @@ -2969,6 +2970,46 @@ print_stat(CPUArchState *cpu_env, const struct sysca= llname *name, #define print_lstat64 print_stat #endif =20 +#if defined(TARGET_NR_madvise) +static struct enums madvise_advice[] =3D { + ENUM_TARGET(MADV_NORMAL), + ENUM_TARGET(MADV_RANDOM), + ENUM_TARGET(MADV_SEQUENTIAL), + ENUM_TARGET(MADV_WILLNEED), + ENUM_TARGET(MADV_DONTNEED), + ENUM_TARGET(MADV_FREE), + ENUM_TARGET(MADV_REMOVE), + ENUM_TARGET(MADV_DONTFORK), + ENUM_TARGET(MADV_DOFORK), + ENUM_TARGET(MADV_MERGEABLE), + ENUM_TARGET(MADV_UNMERGEABLE), + ENUM_TARGET(MADV_HUGEPAGE), + ENUM_TARGET(MADV_NOHUGEPAGE), + ENUM_TARGET(MADV_DONTDUMP), + ENUM_TARGET(MADV_DODUMP), + ENUM_TARGET(MADV_WIPEONFORK), + ENUM_TARGET(MADV_KEEPONFORK), + ENUM_TARGET(MADV_COLD), + ENUM_TARGET(MADV_PAGEOUT), + ENUM_TARGET(MADV_POPULATE_READ), + ENUM_TARGET(MADV_POPULATE_WRITE), + ENUM_TARGET(MADV_DONTNEED_LOCKED), + ENUM_END, +}; + +static void +print_madvise(CPUArchState *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_pointer(arg0, 0); + print_raw_param("%d", arg1, 0); + print_enums(madvise_advice, arg2, 1); + print_syscall_epilogue(name); +} +#endif + #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) static void print_fstat(CPUArchState *cpu_env, const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 72e17b1acf..c93effdbc8 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -541,7 +541,7 @@ { TARGET_NR_lstat64, "lstat64" , NULL, print_lstat64, NULL }, #endif #ifdef TARGET_NR_madvise -{ TARGET_NR_madvise, "madvise" , NULL, NULL, NULL }, +{ TARGET_NR_madvise, "madvise" , NULL, print_madvise, NULL }, #endif #ifdef TARGET_NR_madvise1 { TARGET_NR_madvise1, "madvise1" , NULL, NULL, NULL }, --=20 2.37.2 From nobody Wed May 22 03:22:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1662423102; cv=none; d=zohomail.com; s=zohoarc; b=KB0Kx8ae3PoLLjamEY6Bvpbru23A6LhwmtkEvV11Rj4ZnXUzno+Skv/0V2hobqJKdK2iLLD1+GF7brtgn1VOXgs6tVn66LVGIN+Rn0Mqa1aiIFPu3DZfjBM4rx9psn2fXukpIlb4V75/N2O9NZEvSFAa6Sx3lI8iT3z7+6hKGZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662423102; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=E1wOHpGff2KwNKkukiv3iE6V1QsBdC3zTLNVdsjxZKY=; b=kj5tMmnNbqArVTyuCabvDRN5RcFho++evoebFnn7QT9lK/Tl7nxARjXqzm1pitv1BUOKHw9BNNrJdT5euCyqqIgR9zPzaUNexXyjXbtHdD4go/pU6xdVYJ0a0vdqFQtCs0sCY3B/bNMohf3DuVKDbFlXPZHJH46slE0D1IkmGxM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1662423102679338.2519062078711; Mon, 5 Sep 2022 17:11:42 -0700 (PDT) Received: from localhost ([::1]:37658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVMBp-0006OO-LS for importer@patchew.org; Mon, 05 Sep 2022 20:11:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVM9V-00045O-P6 for qemu-devel@nongnu.org; Mon, 05 Sep 2022 20:09:17 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:11254) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVM9T-0002JU-Ur for qemu-devel@nongnu.org; Mon, 05 Sep 2022 20:09:17 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 285MlqBw021059; Tue, 6 Sep 2022 00:09:13 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jdt7n1q83-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 00:09:12 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 28601HuP005958; Tue, 6 Sep 2022 00:09:12 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jdt7n1q6q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 00:09:12 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 28607GDv028674; Tue, 6 Sep 2022 00:09:09 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma01fra.de.ibm.com with ESMTP id 3jbxj8t770-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 00:09:09 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 286097Mm29950278 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 6 Sep 2022 00:09:07 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 22AAA11C04C; Tue, 6 Sep 2022 00:09:07 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BBA2311C050; Tue, 6 Sep 2022 00:09:06 +0000 (GMT) Received: from heavy.lan (unknown [9.171.53.58]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 6 Sep 2022 00:09:06 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=E1wOHpGff2KwNKkukiv3iE6V1QsBdC3zTLNVdsjxZKY=; b=m89iJxo+nHVRFe5ed6DbTDFX+2DwXobGe61WQoMjXwOrdoR8UqIwFLeGnRCIEd2+9mZN xmN/BkTOT1eoo7cgVpVsmA2NmXpXwKI/Z7leYGj0e0v41t/w94Z1cZYTB+xHgTfF44Hg 23rvepV5/x950Kcwbxszg2MWGWuiILxcwYXPJk9yH3hFlzgLLJFmfZyG0ipuS9EElA+/ 4R65fBZx6WPwW/UHHuQ1RKh8k7u5LkGlRlZgarxfA9Mrwdd1cA/V3Ikkmd92EXVhQThA SEO90d7LC72CDmf2C4p0WQoUejaNAUwe+ewCKNQnnuxOSTnts2AjGO4Wgaex0wsrAMtI HQ== From: Ilya Leoshkevich To: Richard Henderson , Paolo Bonzini , Laurent Vivier , Taylor Simpson , =?UTF-8?q?Alex=20Benn=C3=A9e?= Cc: qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH v3 4/5] linux-user: Passthrough MADV_DONTNEED for certain file mappings Date: Tue, 6 Sep 2022 02:08:38 +0200 Message-Id: <20220906000839.1672934-5-iii@linux.ibm.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220906000839.1672934-1-iii@linux.ibm.com> References: <20220906000839.1672934-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: o8ZKVPkhQcBbaRiDbBmFRCmWn89RpjS3 X-Proofpoint-ORIG-GUID: WU7uQdtl3bMTUd4AnOHlkYzZ7uBtD3dF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-05_16,2022-09-05_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 impostorscore=0 clxscore=1015 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209050118 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1662423103767100001 Content-Type: text/plain; charset="utf-8" This is a follow-up for commit 892a4f6a750a ("linux-user: Add partial support for MADV_DONTNEED"), which added passthrough for anonymous mappings. File mappings can be handled in a similar manner. In order to do that, mark pages, for which mmap() was passed through, with PAGE_PASSTHROUGH, and then allow madvise() passthrough for these pages. Drop the explicit PAGE_ANON check, since anonymous mappings are expected to have PAGE_PASSTHROUGH anyway. Add PAGE_PASSTHROUGH to PAGE_STICKY in order to keep it on mprotect(). Signed-off-by: Ilya Leoshkevich Message-Id: <20220725125043.43048-1-iii@linux.ibm.com> Reviewed-by: Richard Henderson --- accel/tcg/translate-all.c | 2 +- include/exec/cpu-all.h | 6 ++++++ linux-user/mmap.c | 27 ++++++++++++++++++++++----- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index b83161a081..a47cf38e38 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2263,7 +2263,7 @@ int page_get_flags(target_ulong address) #ifndef PAGE_TARGET_STICKY #define PAGE_TARGET_STICKY 0 #endif -#define PAGE_STICKY (PAGE_ANON | PAGE_TARGET_STICKY) +#define PAGE_STICKY (PAGE_ANON | PAGE_PASSTHROUGH | PAGE_TARGET_STICKY) =20 /* Modify the flags of a page and invalidate the code if necessary. The flag PAGE_WRITE_ORG is positioned automatically depending diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 491629b9ba..16b7df41bf 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -262,6 +262,12 @@ extern const TargetPageBits target_page; #define PAGE_TARGET_1 0x0200 #define PAGE_TARGET_2 0x0400 =20 +/* + * For linux-user, indicates that the page is mapped with the same semanti= cs + * in both guest and host. + */ +#define PAGE_PASSTHROUGH 0x0800 + #if defined(CONFIG_USER_ONLY) void page_dump(FILE *f); =20 diff --git a/linux-user/mmap.c b/linux-user/mmap.c index a5f1ab129c..3a0f67619a 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -425,7 +425,8 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size= , abi_ulong align) abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, int flags, int fd, abi_ulong offset) { - abi_ulong ret, end, real_start, real_end, retaddr, host_offset, host_l= en; + abi_ulong ret, end, real_start, real_end, retaddr, host_offset, host_l= en, + passthrough_start =3D -1, passthrough_end =3D -1; int page_flags, host_prot; =20 mmap_lock(); @@ -538,6 +539,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, host_start +=3D offset - host_offset; } start =3D h2g(host_start); + passthrough_start =3D start; + passthrough_end =3D start + len; } else { if (start & ~TARGET_PAGE_MASK) { errno =3D EINVAL; @@ -620,6 +623,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, host_prot, flags, fd, offset1); if (p =3D=3D MAP_FAILED) goto fail; + passthrough_start =3D real_start; + passthrough_end =3D real_end; } } the_end1: @@ -627,7 +632,18 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, i= nt target_prot, page_flags |=3D PAGE_ANON; } page_flags |=3D PAGE_RESET; - page_set_flags(start, start + len, page_flags); + if (passthrough_start =3D=3D passthrough_end) { + page_set_flags(start, start + len, page_flags); + } else { + if (start < passthrough_start) { + page_set_flags(start, passthrough_start, page_flags); + } + page_set_flags(passthrough_start, passthrough_end, + page_flags | PAGE_PASSTHROUGH); + if (passthrough_end < start + len) { + page_set_flags(passthrough_end, start + len, page_flags); + } + } the_end: trace_target_mmap_complete(start); if (qemu_loglevel_mask(CPU_LOG_PAGE)) { @@ -846,7 +862,7 @@ static bool can_passthrough_madv_dontneed(abi_ulong sta= rt, abi_ulong end) } =20 for (addr =3D start; addr < end; addr +=3D TARGET_PAGE_SIZE) { - if (!(page_get_flags(addr) & PAGE_ANON)) { + if (!(page_get_flags(addr) & PAGE_PASSTHROUGH)) { return false; } } @@ -888,8 +904,9 @@ abi_long target_madvise(abi_ulong start, abi_ulong len_= in, int advice) * This is a hint, so ignoring and returning success is ok. * * This breaks MADV_DONTNEED, completely implementing which is quite - * complicated. However, there is one low-hanging fruit: host-page-ali= gned - * anonymous mappings. In this case passthrough is safe, so do it. + * complicated. However, there is one low-hanging fruit: mappings that= are + * known to have the same semantics in the host and the guest. In this= case + * passthrough is safe, so do it. */ mmap_lock(); if (advice =3D=3D TARGET_MADV_DONTNEED && --=20 2.37.2 From nobody Wed May 22 03:22:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1662423532; cv=none; d=zohomail.com; s=zohoarc; b=ObjiBUEyOMnXfGe1b9wBofrcEKO0ugrrQhRG64TQQs4KMmUBHuN3DwnqGlDVu7t5+wo0c+G47ap9SmKBKAM9+96EwiBUMByKT+ywLQR2tL+l/6tCChRxmHF+vdvlhDlpMBoGE8sARrDbWFos9AT/8gJhEnzu3pVhSqABXQcbOOQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662423532; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SJVlNYp2jnCYqwXoOXgMe4CXpegtFcahAJjXjXU3v80=; b=Fsk27ddeKUip5rzptE0fCm/PuC88TbT4bpTBqbqFulyKwYVhijRnAo4TPkQqZbZanZKycsgfmqgqEcKZYKUYask1QvPAzqotEFACM9kP/oN7Uv9s+aliDiQIvJfZu67SZ6BucvNpCsHYP1/IVK/UCq8yj+VURrGyxm5HDzEhb1U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1662423532548597.7350379485347; Mon, 5 Sep 2022 17:18:52 -0700 (PDT) Received: from localhost ([::1]:55412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVMIj-0004XP-WB for importer@patchew.org; Mon, 05 Sep 2022 20:18:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49220) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVM9Z-0004CK-3B for qemu-devel@nongnu.org; Mon, 05 Sep 2022 20:09:21 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:6414) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVM9X-0002Jr-5c for qemu-devel@nongnu.org; Mon, 05 Sep 2022 20:09:20 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 285Nqquj026402; Tue, 6 Sep 2022 00:09:17 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jdu60rfh9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 00:09:17 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 285NqvON026717; Tue, 6 Sep 2022 00:09:16 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jdu60rffu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 00:09:16 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 28606ffJ016399; Tue, 6 Sep 2022 00:09:14 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06ams.nl.ibm.com with ESMTP id 3jbx6hk13c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 00:09:14 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28609B8739190918 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 6 Sep 2022 00:09:11 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CA6F611C04A; Tue, 6 Sep 2022 00:09:11 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6CE3E11C04C; Tue, 6 Sep 2022 00:09:11 +0000 (GMT) Received: from heavy.lan (unknown [9.171.53.58]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 6 Sep 2022 00:09:11 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=SJVlNYp2jnCYqwXoOXgMe4CXpegtFcahAJjXjXU3v80=; b=phrk6tGfElBteAoDPdnobKYmibDmQoLD7nq6iJEGCwIRZEDMx6lmlLRv5dxe3J0GL6kW 2mtNd7wSnComs5QY4bTPMvO0XA3SoeD+gChTRwZ6z3dSlahb4VopqiYK0Og6J3iQ/5q+ IQgVlV1ihekjxQctl5zUpbbCH+Tz37io0pYBogRsk+dNU+n3Goar2i1ATOogPqBBzKEX 121j0S2xIb8g9UvUE6VRplattxyam0hPXxh/qThBs4ydznI8xkskVgRzZDG/UxDSDCC8 AZJRsl1xAEQzPyVbCcjl7BKWmWslEipIFsOqrkxEp9UfzKQlUi/i873MhBe+HHs/dRaw YQ== From: Ilya Leoshkevich To: Richard Henderson , Paolo Bonzini , Laurent Vivier , Taylor Simpson , =?UTF-8?q?Alex=20Benn=C3=A9e?= Cc: qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH v3 5/5] tests/tcg/linux-test: Add linux-madvise test Date: Tue, 6 Sep 2022 02:08:39 +0200 Message-Id: <20220906000839.1672934-6-iii@linux.ibm.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220906000839.1672934-1-iii@linux.ibm.com> References: <20220906000839.1672934-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: i5vt7sTOt71Q84e8lzkA2jN3GLLpJNBh X-Proofpoint-ORIG-GUID: k4ShOq4VMQVUaSO9aVNgsv3r-3AkV3s4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-05_16,2022-09-05_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxlogscore=948 suspectscore=0 bulkscore=0 priorityscore=1501 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 adultscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209050118 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1662423532981100001 Content-Type: text/plain; charset="utf-8" Add a test that checks madvise(MADV_DONTNEED) behavior with anonymous and file mappings in order to prevent regressions. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson --- tests/tcg/multiarch/linux/linux-madvise.c | 70 +++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 tests/tcg/multiarch/linux/linux-madvise.c diff --git a/tests/tcg/multiarch/linux/linux-madvise.c b/tests/tcg/multiarc= h/linux/linux-madvise.c new file mode 100644 index 0000000000..29d0997e68 --- /dev/null +++ b/tests/tcg/multiarch/linux/linux-madvise.c @@ -0,0 +1,70 @@ +#include +#include +#include +#include + +static void test_anonymous(void) +{ + int pagesize =3D getpagesize(); + char *page; + int ret; + + page =3D mmap(NULL, pagesize, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, = -1, 0); + assert(page !=3D MAP_FAILED); + + /* Check that mprotect() does not interfere with MADV_DONTNEED. */ + ret =3D mprotect(page, pagesize, PROT_READ | PROT_WRITE); + assert(ret =3D=3D 0); + + /* Check that MADV_DONTNEED clears the page. */ + *page =3D 42; + ret =3D madvise(page, pagesize, MADV_DONTNEED); + assert(ret =3D=3D 0); + assert(*page =3D=3D 0); + + ret =3D munmap(page, pagesize); + assert(ret =3D=3D 0); +} + +static void test_file(void) +{ + char tempname[] =3D "/tmp/.cmadviseXXXXXX"; + int pagesize =3D getpagesize(); + ssize_t written; + char c =3D 42; + char *page; + int ret; + int fd; + + fd =3D mkstemp(tempname); + assert(fd !=3D -1); + ret =3D unlink(tempname); + assert(ret =3D=3D 0); + written =3D write(fd, &c, sizeof(c)); + assert(written =3D=3D sizeof(c)); + page =3D mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE, fd, 0); + assert(page !=3D MAP_FAILED); + + /* Check that mprotect() does not interfere with MADV_DONTNEED. */ + ret =3D mprotect(page, pagesize, PROT_READ | PROT_WRITE); + assert(ret =3D=3D 0); + + /* Check that MADV_DONTNEED resets the page. */ + *page =3D 0; + ret =3D madvise(page, pagesize, MADV_DONTNEED); + assert(ret =3D=3D 0); + assert(*page =3D=3D c); + + ret =3D munmap(page, pagesize); + assert(ret =3D=3D 0); + ret =3D close(fd); + assert(ret =3D=3D 0); +} + +int main(void) +{ + test_anonymous(); + test_file(); + + return EXIT_SUCCESS; +} --=20 2.37.2