From patchwork Tue Feb 8 20:08:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 540808 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp811075imo; Tue, 8 Feb 2022 13:08:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJy46uF/OnHVJf7QD0RBcY5MJmU4QHiGQhcn0SlLxJBnbuiytej+zgskZf9ACO6VRjhSsD8S X-Received: by 2002:a25:30d4:: with SMTP id w203mr2028981ybw.511.1644354498573; Tue, 08 Feb 2022 13:08:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644354498; cv=none; d=google.com; s=arc-20160816; b=KQNe11XJZl5IxK3nfPFH/2bJjUHXgpYwWMRWyXNJAYehG17ciXWtb0GBPdw5495iVP yLZyzZweXuSnT7SRCwA8NzWLsxBCh91hC1yu5usARY+/qNdqkV7lCnymXHeTB/0h+qVQ 2Sp9QhXRueFAnpvDL02al4qcKUQ3zzthO+KAi0IKdDN1KrJAjwTZVQigLv6gVzlQ9o0m h4C2pTyv6FKHPMsIuWIuDhMm8PnSxg0FCAfqM0t52wtBVF1pb9L7Y4CNJLP5KoCrYjy6 O+KwAbbMWTuMV4M0krXZfmMVxwvxqYtkZnSR8oOURCGz7O9k29BssflDUGEX82g3QIBy e6Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=om0XV2oCryM431P+Rv/gpC75TuXJHNl3A2Oh1Kcr5Ic=; b=GnVO/WnlB/BGm4e1nL7GP8nNa9TUauG0VdYoBupXbXIvQuaCy/NpXmObtzqQVFDlNV jUqsQNBvx3Ack9UG4Hk3rUQQtyKo8vk1cJoV7hp5+ASOfuexdqhEIS/Bw56gUD7W2rcA 3/bfP5sFhhRIb2mZ4ZBmxJPZVtcj0GZ6otVwFBF5KXFw4PL/o5/6uCqu3MmqgW0nkk13 AMfcT7f4pqltoUAaJmsDrzzBYJHojU9pFP+1F5jIAi7Bduv2RTszAXKEXePBj9spDiL1 jREKVWZvx5fpWS6hi9R3RmdRMHo4bJHTsMWAmX7T4DKNTbaQyFH0ReoV1bZGSgLOJ4h5 C/WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wq2rRXqc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m8si7030813ywm.431.2022.02.08.13.08.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Feb 2022 13:08:18 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wq2rRXqc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHXij-0003yK-W4 for patch@linaro.org; Tue, 08 Feb 2022 16:08:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHWnV-00030z-Ot for qemu-devel@nongnu.org; Tue, 08 Feb 2022 15:09:09 -0500 Received: from [2a00:1450:4864:20::429] (port=35568 helo=mail-wr1-x429.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHWnT-00066T-15 for qemu-devel@nongnu.org; Tue, 08 Feb 2022 15:09:09 -0500 Received: by mail-wr1-x429.google.com with SMTP id v12so386564wrv.2 for ; Tue, 08 Feb 2022 12:09:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=om0XV2oCryM431P+Rv/gpC75TuXJHNl3A2Oh1Kcr5Ic=; b=wq2rRXqcRat9rMwI7X7oUpR8Mi17NY8D6y5y2+1WN1EwKqBSSPPij3RPFVj7IUPQqz G+5PrcDyRroikq4l9swoCT9kYgbXmq+SvzYXvKEz39c17cSziNVNMaKcuu6+w+um3I5/ KQWfuXyfP0M9wllD85WZ9y/W0/j+b4tnwCgQSuB5mqk+lKzNzOHq00X8phESmuMQpedq Vj5TU6KcboCuxBNgNgX9NqgJSoPi02JayxxUTaqXlfWq75UqNjjJar1vVccAWQWNYFX3 cd3ztrkIAaY9M1s6fhz0CDLMoDq7w4yvcNhqloJ7Cz9f2w4hZkGiuTM9HbJmMxY6/ZGL JT7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=om0XV2oCryM431P+Rv/gpC75TuXJHNl3A2Oh1Kcr5Ic=; b=H7qq/jU9WfcuMB4OC612qRLgjemBw4jc9pfcJnIwsAar6a67eed+KNBDdoIRFMYT/K 5wSC50AnZeRrD5Lf7YuaOI5falQgHPJubKS66IjPVPGqJgIYeytxti8aXUk94doSNHoO KZ0V/vUvJqlLlElNemhoWqs8wWISaygNKFOD7C03zpoiGc4syiMl/kMXrTcYq9RaTDzT ocIRa2K7qZhRGFOXjFdyBKpaleKzC4J4/6dhgbfGHjWpxGTLdGtJ19S8K5UaaZp4A810 RfMhGkolHHwt/0s6HnEebbEKXdjEtivxvHBks1mESqRSiVaajnQaNDqCXEAv+/ujKT65 owYg== X-Gm-Message-State: AOAM531V+4aAmycU6AosAiBg34nDuJj7k1oDxaOgsGCoOFf5wqyDjIn4 FBDWXp+YcwGG18F0ttfMjjVidJ30I3Uv5g== X-Received: by 2002:a5d:4945:: with SMTP id r5mr4763011wrs.450.1644350939339; Tue, 08 Feb 2022 12:08:59 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id r2sm4098170wmq.24.2022.02.08.12.08.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 12:08:59 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH 1/5] include: Move qemu_madvise() and related #defines to new qemu/madvise.h Date: Tue, 8 Feb 2022 20:08:52 +0000 Message-Id: <20220208200856.3558249-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208200856.3558249-1-peter.maydell@linaro.org> References: <20220208200856.3558249-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::429 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The function qemu_madvise() and the QEMU_MADV_* constants associated with it are used in only 10 files. Move them out of osdep.h to a new qemu/madvise.h header that is included where it is needed. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- include/qemu/madvise.h | 95 ++++++++++++++++++++++++++++++++++++++ include/qemu/osdep.h | 82 -------------------------------- backends/hostmem-file.c | 1 + backends/hostmem.c | 1 + hw/virtio/virtio-balloon.c | 1 + migration/postcopy-ram.c | 1 + migration/qemu-file.c | 1 + migration/ram.c | 1 + softmmu/physmem.c | 1 + tcg/region.c | 1 + util/osdep.c | 1 + util/oslib-posix.c | 1 + 12 files changed, 105 insertions(+), 82 deletions(-) create mode 100644 include/qemu/madvise.h diff --git a/include/qemu/madvise.h b/include/qemu/madvise.h new file mode 100644 index 00000000000..e155f59a0df --- /dev/null +++ b/include/qemu/madvise.h @@ -0,0 +1,95 @@ +/* + * QEMU madvise wrapper functions + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_MADVISE_H +#define QEMU_MADVISE_H + +#define QEMU_MADV_INVALID -1 + +#if defined(CONFIG_MADVISE) + +#define QEMU_MADV_WILLNEED MADV_WILLNEED +#define QEMU_MADV_DONTNEED MADV_DONTNEED +#ifdef MADV_DONTFORK +#define QEMU_MADV_DONTFORK MADV_DONTFORK +#else +#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID +#endif +#ifdef MADV_MERGEABLE +#define QEMU_MADV_MERGEABLE MADV_MERGEABLE +#else +#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID +#endif +#ifdef MADV_UNMERGEABLE +#define QEMU_MADV_UNMERGEABLE MADV_UNMERGEABLE +#else +#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID +#endif +#ifdef MADV_DODUMP +#define QEMU_MADV_DODUMP MADV_DODUMP +#else +#define QEMU_MADV_DODUMP QEMU_MADV_INVALID +#endif +#ifdef MADV_DONTDUMP +#define QEMU_MADV_DONTDUMP MADV_DONTDUMP +#else +#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID +#endif +#ifdef MADV_HUGEPAGE +#define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE +#else +#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID +#endif +#ifdef MADV_NOHUGEPAGE +#define QEMU_MADV_NOHUGEPAGE MADV_NOHUGEPAGE +#else +#define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID +#endif +#ifdef MADV_REMOVE +#define QEMU_MADV_REMOVE MADV_REMOVE +#else +#define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED +#endif +#ifdef MADV_POPULATE_WRITE +#define QEMU_MADV_POPULATE_WRITE MADV_POPULATE_WRITE +#else +#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID +#endif + +#elif defined(CONFIG_POSIX_MADVISE) + +#define QEMU_MADV_WILLNEED POSIX_MADV_WILLNEED +#define QEMU_MADV_DONTNEED POSIX_MADV_DONTNEED +#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID +#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID +#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID +#define QEMU_MADV_DODUMP QEMU_MADV_INVALID +#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID +#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID +#define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID +#define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED +#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID + +#else /* no-op */ + +#define QEMU_MADV_WILLNEED QEMU_MADV_INVALID +#define QEMU_MADV_DONTNEED QEMU_MADV_INVALID +#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID +#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID +#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID +#define QEMU_MADV_DODUMP QEMU_MADV_INVALID +#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID +#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID +#define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID +#define QEMU_MADV_REMOVE QEMU_MADV_INVALID +#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID + +#endif + +int qemu_madvise(void *addr, size_t len, int advice); + +#endif diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index d1660d67fa9..cb74f4571a3 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -425,87 +425,6 @@ static inline void qemu_cleanup_generic_vfree(void *p) #define QEMU_MAP_NORESERVE (1 << 3) -#define QEMU_MADV_INVALID -1 - -#if defined(CONFIG_MADVISE) - -#define QEMU_MADV_WILLNEED MADV_WILLNEED -#define QEMU_MADV_DONTNEED MADV_DONTNEED -#ifdef MADV_DONTFORK -#define QEMU_MADV_DONTFORK MADV_DONTFORK -#else -#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID -#endif -#ifdef MADV_MERGEABLE -#define QEMU_MADV_MERGEABLE MADV_MERGEABLE -#else -#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID -#endif -#ifdef MADV_UNMERGEABLE -#define QEMU_MADV_UNMERGEABLE MADV_UNMERGEABLE -#else -#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID -#endif -#ifdef MADV_DODUMP -#define QEMU_MADV_DODUMP MADV_DODUMP -#else -#define QEMU_MADV_DODUMP QEMU_MADV_INVALID -#endif -#ifdef MADV_DONTDUMP -#define QEMU_MADV_DONTDUMP MADV_DONTDUMP -#else -#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID -#endif -#ifdef MADV_HUGEPAGE -#define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE -#else -#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID -#endif -#ifdef MADV_NOHUGEPAGE -#define QEMU_MADV_NOHUGEPAGE MADV_NOHUGEPAGE -#else -#define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID -#endif -#ifdef MADV_REMOVE -#define QEMU_MADV_REMOVE MADV_REMOVE -#else -#define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED -#endif -#ifdef MADV_POPULATE_WRITE -#define QEMU_MADV_POPULATE_WRITE MADV_POPULATE_WRITE -#else -#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID -#endif - -#elif defined(CONFIG_POSIX_MADVISE) - -#define QEMU_MADV_WILLNEED POSIX_MADV_WILLNEED -#define QEMU_MADV_DONTNEED POSIX_MADV_DONTNEED -#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID -#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID -#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID -#define QEMU_MADV_DODUMP QEMU_MADV_INVALID -#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID -#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID -#define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID -#define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED -#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID - -#else /* no-op */ - -#define QEMU_MADV_WILLNEED QEMU_MADV_INVALID -#define QEMU_MADV_DONTNEED QEMU_MADV_INVALID -#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID -#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID -#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID -#define QEMU_MADV_DODUMP QEMU_MADV_INVALID -#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID -#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID -#define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID -#define QEMU_MADV_REMOVE QEMU_MADV_INVALID -#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID - -#endif #ifdef _WIN32 #define HAVE_CHARDEV_SERIAL 1 @@ -577,7 +496,6 @@ void sigaction_invoke(struct sigaction *action, struct qemu_signalfd_siginfo *info); #endif -int qemu_madvise(void *addr, size_t len, int advice); int qemu_mprotect_rw(void *addr, size_t size); int qemu_mprotect_rwx(void *addr, size_t size); int qemu_mprotect_none(void *addr, size_t size); diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index cd038024fae..25141283c4a 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -14,6 +14,7 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/module.h" +#include "qemu/madvise.h" #include "sysemu/hostmem.h" #include "qom/object_interfaces.h" #include "qom/object.h" diff --git a/backends/hostmem.c b/backends/hostmem.c index 4c05862ed5a..b2a5e905e86 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -19,6 +19,7 @@ #include "qemu/config-file.h" #include "qom/object_interfaces.h" #include "qemu/mmap-alloc.h" +#include "qemu/madvise.h" #ifdef CONFIG_NUMA #include diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 9a4f491b54d..e6c1b0aa46f 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -17,6 +17,7 @@ #include "qemu/iov.h" #include "qemu/module.h" #include "qemu/timer.h" +#include "qemu/madvise.h" #include "hw/virtio/virtio.h" #include "hw/mem/pc-dimm.h" #include "hw/qdev-properties.h" diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index e662dd05ccf..2a2cc5faf8f 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -18,6 +18,7 @@ #include "qemu/osdep.h" #include "qemu/rcu.h" +#include "qemu/madvise.h" #include "exec/target_page.h" #include "migration.h" #include "qemu-file.h" diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 6338d8e2ff5..1479cddad94 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -23,6 +23,7 @@ */ #include "qemu/osdep.h" #include +#include "qemu/madvise.h" #include "qemu/error-report.h" #include "qemu/iov.h" #include "migration.h" diff --git a/migration/ram.c b/migration/ram.c index 91ca743ac88..781f0745dc0 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -30,6 +30,7 @@ #include "qemu/cutils.h" #include "qemu/bitops.h" #include "qemu/bitmap.h" +#include "qemu/madvise.h" #include "qemu/main-loop.h" #include "xbzrle.h" #include "ram.h" diff --git a/softmmu/physmem.c b/softmmu/physmem.c index dddf70edf5d..a13289a594a 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -23,6 +23,7 @@ #include "qemu/cutils.h" #include "qemu/cacheflush.h" +#include "qemu/madvise.h" #ifdef CONFIG_TCG #include "hw/core/tcg-cpu-ops.h" diff --git a/tcg/region.c b/tcg/region.c index 9cc30d49225..c46021d1604 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -24,6 +24,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/madvise.h" #include "qapi/error.h" #include "exec/exec-all.h" #include "tcg/tcg.h" diff --git a/util/osdep.c b/util/osdep.c index 42a0a4986ae..1999f42f6fc 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -37,6 +37,7 @@ extern int madvise(char *, size_t, int); #include "qemu/cutils.h" #include "qemu/sockets.h" #include "qemu/error-report.h" +#include "qemu/madvise.h" #include "monitor/monitor.h" static bool fips_enabled = false; diff --git a/util/oslib-posix.c b/util/oslib-posix.c index ac0dbc2adc2..f2be7321c59 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -36,6 +36,7 @@ #include "trace.h" #include "qapi/error.h" #include "qemu/error-report.h" +#include "qemu/madvise.h" #include "qemu/sockets.h" #include "qemu/thread.h" #include From patchwork Tue Feb 8 20:08:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 540804 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp779367imo; Tue, 8 Feb 2022 12:13:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQw5e8nv6b7uGPb5/I9K+PCsAu+2V0VveJZ3xk+9JZvRh3tfzyjEHXaNliCSnpEjMCBGed X-Received: by 2002:a25:44c4:: with SMTP id r187mr6216162yba.51.1644351185228; Tue, 08 Feb 2022 12:13:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644351185; cv=none; d=google.com; s=arc-20160816; b=ey1UPXsOYL7W/DlQQvHrsYFAr2D94u0DoHwXyZRo8uwTdr//bNK3boejAyRh0OvRxd RsdYqTYSWXcXueh0qbNqKCLAZg+nhzvPbH05NR4DvpCuGk8e1ymvN+3ql9RuyhAHNoZE fjIYlbcwPOZX48eemKv0iTl9+tiOHMA9poo7bRwXS36CwgalxajOJVcotHLAyRF4DAt1 GYgYxSTkOfI/TwUdgkVI03Q1pgZ3mL5+tYws4YoX313PjW13WcP/Oq+ZjfZWUouiDXGf 49NkkMza715ewJMEUj9d3zkniCS/8oIGZFpEfbnpf25WvIfz1958enQqXExhtEMgNzhE qm3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Kvt1TfUvKKE2DWl3Q8+xXwyGqPqxYFhXR1/NgDzzilg=; b=uPfz1y9+sVvNfwUuGbx3ClJVEUQqa6mhrnoDdGx7JwWhoGz2x9gUrWwWqIrbVP25+P svGY1vXl6+eX2LeugKsBEj6TTueZmsRr+0szeO/ThEAFjOm8GvCqC4nPiThibaVKHukJ kLTSmR0mFIdVp9FlEmqxZea1f8f9Fc6h2WO5nI0zpvpXEYuB1G65fVpPUZhvae/TFjxX Tk8FoomZyB03gEnqP941KiNOhGJOUgtC2oXJ/bnAq18YMpu01g/sgwuUtyC4bsll1BSu 4OVaXEbCc24nTw86kCA6rfY/2luYSOC1v8pQ8ksFMcRoym8LlYE8qJgAYssU7Ct4I3rx lH9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XfRZ9eXJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a128si11192100ywh.34.2022.02.08.12.13.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Feb 2022 12:13:05 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XfRZ9eXJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHWrI-0003AC-LA for patch@linaro.org; Tue, 08 Feb 2022 15:13:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHWnX-00032E-83 for qemu-devel@nongnu.org; Tue, 08 Feb 2022 15:09:13 -0500 Received: from [2a00:1450:4864:20::435] (port=47095 helo=mail-wr1-x435.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHWnT-00066b-4b for qemu-devel@nongnu.org; Tue, 08 Feb 2022 15:09:10 -0500 Received: by mail-wr1-x435.google.com with SMTP id q7so277640wrc.13 for ; Tue, 08 Feb 2022 12:09:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Kvt1TfUvKKE2DWl3Q8+xXwyGqPqxYFhXR1/NgDzzilg=; b=XfRZ9eXJkcIeBR4roww+GdKRs5Wx0H8FCzovdbN4IBRtDg++jFP8cohPRxipRFiZKI C16EA+jC2vf7w4Ni7SxcahAf4p+1gwkM6AfhQ9eG4j/uWMeLtX+LEy1y35eB//so+DlN gxxt7rLqGPSmIjhMHq4MXBbN1wPtK3y4f4/H8J8okFTuPwwN5uiktuP/jYCR0iwJFXAl qPp8j+S55YH1jBrvn10093G3bRO76gh80svjTixvj/1WoQ2Mjv8iUrRLQIfedI2GBMvh 4PCdk1w+dJjtvDJ+4GoSH5qaqXNiwiE6flie3uq1l7PxnKZkaxB3hsSJCn4TkXs3+kq+ HhKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kvt1TfUvKKE2DWl3Q8+xXwyGqPqxYFhXR1/NgDzzilg=; b=wxK6QqzjBtrXjuYUUe8dNY3+72tRxGf/YWCjkOo/7zdwoDiSg3TsoF19NwA25Uk1WX ymjNKeNSWQQBoKt2GFEgMFcYC0eifv7IwIT2Q01S6xYB2t5eLxN2yjPLvM2BbQUpPqPf TMReZ1jYpTToz02diFsm1FJTntsE5uP/76sqftMSzFevYp8bh+3wHxynIAEDwpIxuzkD xRUoIlz/xMB1XK2EvugM26OZ6zcnWbYehrLnkOSVEyIlaP/srH2bX8ujeciswWClbcEj tj0dDegPAiAtk1j3+4k195dwZeyEQeiFxqABOGaG8Q/YMwr57SArz0c2ch+O+pfnYK72 dOCA== X-Gm-Message-State: AOAM531uIA0VmUWncVXCcY10l9MKgI7hxSmkXzKpmozVlo7T41VjiPgs BYwz38MjwZIqhy12FKzAyA8my3sMfYZzpw== X-Received: by 2002:a05:6000:1869:: with SMTP id d9mr4784644wri.432.1644350939909; Tue, 08 Feb 2022 12:08:59 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id r2sm4098170wmq.24.2022.02.08.12.08.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 12:08:59 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH 2/5] include: Move qemu_mprotect_*() to new qemu/mprotect.h Date: Tue, 8 Feb 2022 20:08:53 +0000 Message-Id: <20220208200856.3558249-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208200856.3558249-1-peter.maydell@linaro.org> References: <20220208200856.3558249-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::435 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The qemu_mprotect_*() family of functions are used in very few files; move them from osdep.h to a new qemu/mprotect.h. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- include/qemu/mprotect.h | 14 ++++++++++++++ include/qemu/osdep.h | 4 ---- tcg/region.c | 1 + util/osdep.c | 1 + 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 include/qemu/mprotect.h diff --git a/include/qemu/mprotect.h b/include/qemu/mprotect.h new file mode 100644 index 00000000000..1e83d1433ee --- /dev/null +++ b/include/qemu/mprotect.h @@ -0,0 +1,14 @@ +/* + * QEMU mprotect functions + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#ifndef QEMU_MPROTECT_H +#define QEMU_MPROTECT_H + +int qemu_mprotect_rw(void *addr, size_t size); +int qemu_mprotect_rwx(void *addr, size_t size); +int qemu_mprotect_none(void *addr, size_t size); + +#endif diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index cb74f4571a3..2a52933ce0e 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -496,10 +496,6 @@ void sigaction_invoke(struct sigaction *action, struct qemu_signalfd_siginfo *info); #endif -int qemu_mprotect_rw(void *addr, size_t size); -int qemu_mprotect_rwx(void *addr, size_t size); -int qemu_mprotect_none(void *addr, size_t size); - /* * Don't introduce new usage of this function, prefer the following * qemu_open/qemu_create that take an "Error **errp" diff --git a/tcg/region.c b/tcg/region.c index c46021d1604..7b4e65a52e8 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -25,6 +25,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" #include "qemu/madvise.h" +#include "qemu/mprotect.h" #include "qapi/error.h" #include "exec/exec-all.h" #include "tcg/tcg.h" diff --git a/util/osdep.c b/util/osdep.c index 1999f42f6fc..72b678ca2e3 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -38,6 +38,7 @@ extern int madvise(char *, size_t, int); #include "qemu/sockets.h" #include "qemu/error-report.h" #include "qemu/madvise.h" +#include "qemu/mprotect.h" #include "monitor/monitor.h" static bool fips_enabled = false; From patchwork Tue Feb 8 20:08:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 540803 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp779247imo; Tue, 8 Feb 2022 12:12:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzU2EvNLYkhTR9Vr2NcFN+f5Yv1pZb7IH/4rO0UJDyFIx57Ot08fSRY1SW2E3m/GVU8pTbU X-Received: by 2002:a25:84c5:: with SMTP id x5mr678169ybm.747.1644351173400; Tue, 08 Feb 2022 12:12:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644351173; cv=none; d=google.com; s=arc-20160816; b=GlyrKBIbP3gHoONYgh2pzELTwhGTCWveWy7Zag6FWXfWktys2/Yu5N9MjCcpCJl9TO sc96CLXkHl8mt7D+l9s+jXIGEOYL4YYuyjEzytOCXKLTY9l6iiXqzAFBxlNwFcgK9Lqn kJV2sazFjLqvkZENLmxMt3yVm21/7IKc1Fn9y4XtXYKTkHFk2u2ugkmb5AblCwTx+OHZ 7uQ3SWS74ba/n8Ew7wI7bhKgjsyTmjU9gkl1ctQ/R7Z1yCx/Tbl/ExTUpxpqNwtLRvIW F9f1Q8qgFmbgCW5I9XXQm2zC+YdEP3uCxETPoLIgUQUfh6b8+HBG1SHT/aQmr5r9x4ei WhDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=PrbYqH6sR5gz/Fz8Pqq4CFLsp5TPR2lRR6F+G57Ib0U=; b=nPNsNk/dBLhcWK5X4jkNrIwSdLMEbFdgdlALYNtFfBdbsUx4XTL1uKUdsc1G60TkmB KJGdcU4vI7KmcxZP4UzkB82PFQgig+DXlaXL2NbddwCKxoiLo6lC8pGjilaoN2fowIHf O+IJUO15VKjSNtVMDk1498kNJ7TAUGIKozPJlw5QHvL2TKUdppc0OOO2zi2g79VfX/xb kFWyO6ByQB6TV+ap76U12+mEg5LZZATnGl23GYeAQWZih8FE2HO0hJNKoOpucaAQMWk0 n/mrj7aOnCcFscBFZ9c/K/J4hfY/3xkvVGS+SUsuo+SAQQv6lE1iw0Qwpi7/oWvRgVfc 0TBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xYFevFOP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x11si11719913ybu.622.2022.02.08.12.12.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Feb 2022 12:12:53 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xYFevFOP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHWr6-00034Q-TE for patch@linaro.org; Tue, 08 Feb 2022 15:12:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHWnY-00032K-6g for qemu-devel@nongnu.org; Tue, 08 Feb 2022 15:09:13 -0500 Received: from [2a00:1450:4864:20::42a] (port=41535 helo=mail-wr1-x42a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHWnT-00066f-3t for qemu-devel@nongnu.org; Tue, 08 Feb 2022 15:09:11 -0500 Received: by mail-wr1-x42a.google.com with SMTP id k1so336047wrd.8 for ; Tue, 08 Feb 2022 12:09:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PrbYqH6sR5gz/Fz8Pqq4CFLsp5TPR2lRR6F+G57Ib0U=; b=xYFevFOPEzZ2XneBLARpjsj9i8smYzoSqvvQJ21OSJH7kD2AEEY0mEGcguKWcd+l76 8sU8blbrJCrNCKUYwNCWyd8YVOuT4uc3buNb/EkQlyMW2C0kmXgWeGvLn30ChVGvUqbi IR5ZkherU6UDaku1tFdv+FdcbLf+IDUbaqW1RCh5zCGiOKuD7/BwUYmlBWz/PknxyJ7x z2/hqqpADDr/sOLgGlPUw4pSAoQjjWudxOzhTEPN8AXIo+vtjFxdvZEZ2fE0DZbokQ6U 8AkSy5bAj+a5RBzBa5vxQbSzdhGCl8houc+kLj9MpxhQIWsPSDInEuRv+n+GrERjdnzy TLhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PrbYqH6sR5gz/Fz8Pqq4CFLsp5TPR2lRR6F+G57Ib0U=; b=e80hu5wH5GoY7cewPbHfwzWtjgmRyF/XoPR3hEzaiGmoHsX/tclvfuNIROap4iFeqD j/oqNsoD9qNnSpn/xh/1fVcn+98YaQGgYdpZYF8j7O+b11uLI9cXNBXKAoNYXGcYtWQw /tMzUmSCCjTNn7epMHjdF1Ag2jj3uMZ/MWI/b94/s5HY6S//i8HhGa4sTSaL3+A6o1Cg sCWVKwbGbP64s0YX2+0rw0NoKGqwKtDgkFv3oqjvqI05v+AP3Z7hbmA0eHeq0XfiX/BG 9KBp9DBUK1NVLFiFcT0jRoU3yaVIM/+Rq1GJp+oUcxqFBwuU1OhgGF1PXibOV38R0wBe /Oig== X-Gm-Message-State: AOAM531eN32epTcxcpcezMeZvcwuqoGr3tQl1av6095hXOKG63XSCpV/ fMKMx/MvHc+LaEOn92gQTu0TtcMdQIA0Bw== X-Received: by 2002:adf:fecf:: with SMTP id q15mr4713762wrs.104.1644350940655; Tue, 08 Feb 2022 12:09:00 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id r2sm4098170wmq.24.2022.02.08.12.09.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 12:09:00 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH 3/5] include: Move QEMU_MAP_* constants to mmap-alloc.h Date: Tue, 8 Feb 2022 20:08:54 +0000 Message-Id: <20220208200856.3558249-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208200856.3558249-1-peter.maydell@linaro.org> References: <20220208200856.3558249-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42a (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The QEMU_MAP_* constants are used only as arguments to the qemu_ram_mmap() function. Move them to mmap-alloc.h, where that function's prototype is defined. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- include/qemu/mmap-alloc.h | 23 +++++++++++++++++++++++ include/qemu/osdep.h | 25 ------------------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/include/qemu/mmap-alloc.h b/include/qemu/mmap-alloc.h index 90d0eee7053..5076695cc81 100644 --- a/include/qemu/mmap-alloc.h +++ b/include/qemu/mmap-alloc.h @@ -35,4 +35,27 @@ void *qemu_ram_mmap(int fd, void qemu_ram_munmap(int fd, void *ptr, size_t size); +/* + * Abstraction of PROT_ and MAP_ flags as passed to mmap(), for example, + * consumed by qemu_ram_mmap(). + */ + +/* Map PROT_READ instead of PROT_READ | PROT_WRITE. */ +#define QEMU_MAP_READONLY (1 << 0) + +/* Use MAP_SHARED instead of MAP_PRIVATE. */ +#define QEMU_MAP_SHARED (1 << 1) + +/* + * Use MAP_SYNC | MAP_SHARED_VALIDATE if supported. Ignored without + * QEMU_MAP_SHARED. If mapping fails, warn and fallback to !QEMU_MAP_SYNC. + */ +#define QEMU_MAP_SYNC (1 << 2) + +/* + * Use MAP_NORESERVE to skip reservation of swap space (or huge pages if + * applicable). Bail out if not supported/effective. + */ +#define QEMU_MAP_NORESERVE (1 << 3) + #endif diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 2a52933ce0e..0715d6b4509 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -401,31 +401,6 @@ static inline void qemu_cleanup_generic_vfree(void *p) */ #define QEMU_AUTO_VFREE __attribute__((cleanup(qemu_cleanup_generic_vfree))) -/* - * Abstraction of PROT_ and MAP_ flags as passed to mmap(), for example, - * consumed by qemu_ram_mmap(). - */ - -/* Map PROT_READ instead of PROT_READ | PROT_WRITE. */ -#define QEMU_MAP_READONLY (1 << 0) - -/* Use MAP_SHARED instead of MAP_PRIVATE. */ -#define QEMU_MAP_SHARED (1 << 1) - -/* - * Use MAP_SYNC | MAP_SHARED_VALIDATE if supported. Ignored without - * QEMU_MAP_SHARED. If mapping fails, warn and fallback to !QEMU_MAP_SYNC. - */ -#define QEMU_MAP_SYNC (1 << 2) - -/* - * Use MAP_NORESERVE to skip reservation of swap space (or huge pages if - * applicable). Bail out if not supported/effective. - */ -#define QEMU_MAP_NORESERVE (1 << 3) - - - #ifdef _WIN32 #define HAVE_CHARDEV_SERIAL 1 #elif defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ From patchwork Tue Feb 8 20:08:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 540806 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp794409imo; Tue, 8 Feb 2022 12:39:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHkQdVoH3e1QSikUNGlTJzJWT/maL5fk3QUi6GLbz94sSReC/zVEuwbmKYV/HwWDzC34LR X-Received: by 2002:a81:a391:: with SMTP id a139mr6703059ywh.432.1644352776305; Tue, 08 Feb 2022 12:39:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644352776; cv=none; d=google.com; s=arc-20160816; b=j7kajBqw+J3STFvQCsftnQ+vGl8f4NojI1joplZSh9Bn7R0o3zLB+oZl5YerPF3y8r J0iO18i3SaHYI75+3A1VUVRFMevurxdIOHXU7eUe+1NOYHvYyYg/Bd4A/afgAQYOOaqB N1ztKIYwj1UkEI5HNdgDPOyAFha3gga0+3wJ9crtfsO/36iZeCocEV4moKTFcmraMef5 l7vxeYQJJHgVNl4aQ6yYus1ViOANLjX10hiK7vKCEE9zoHzOgnMd99+Vv7J+CnbE/CgM oxBzkzInbPBseg+NR517yc8yaqBYjDc1C0ybFFbamjvZuDbWD9WRvFqu/6e1QdQkP9Ih 7ZoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ETqgvEp+BK5IeQcaommUlEe8fKOhJ00KVNdgTbqltH8=; b=nwYOUQP5btU8Y++74QMiS8FIFOFWj4k1sZDV0P0V4Eq1JPF0UbYaCiAvn2k+NFI7qQ ImhKe7Petvprv0KiKNaEof/J7Vnr6bHBO5Kou1VY4Atcy0FaCEhdBbaL5pyxmGO49i+h E+T/osrPJcrffeD1bvIqO0OAsSo0foTTmEZFe+Im9FMcQjNFexVat5SVkNmBQy4o35T0 5MYUBAfrO0VRxchMbHCIRHKkQ6wgxDKbmtqYISsu9Okd4YF07bQxsvg6zaikmzEV3hj0 UJhZsq/z5kKuV0IqntR+MbilEiFPSp7s5eNNuLLavIOLrjB9eme4NdtiGnhuJh3ddf2o 7Rrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U1VpaWHh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c138si3265307ywa.10.2022.02.08.12.39.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Feb 2022 12:39:36 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U1VpaWHh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:35234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHXGx-0003AW-CX for patch@linaro.org; Tue, 08 Feb 2022 15:39:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHWna-00033B-5R for qemu-devel@nongnu.org; Tue, 08 Feb 2022 15:09:18 -0500 Received: from [2a00:1450:4864:20::32e] (port=54789 helo=mail-wm1-x32e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHWnT-00066j-5X for qemu-devel@nongnu.org; Tue, 08 Feb 2022 15:09:12 -0500 Received: by mail-wm1-x32e.google.com with SMTP id c192so47564wma.4 for ; Tue, 08 Feb 2022 12:09:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ETqgvEp+BK5IeQcaommUlEe8fKOhJ00KVNdgTbqltH8=; b=U1VpaWHhRQNMbt1U6lyGf2VMPrnhc7HKy3/HXFDyPRLDCCvck1COXPz4picyc/6I5i oxUL64BXGVvUz0UoSi+8VyNXiKvd4Rtdqu+zg0ryXqD4zECjWEweAPstt2IPNBtxejpP LqErd5ngjHAMXCdi6TaR2tQNBH37BWVQH9X52vMw2i+L24V+g0oh2bCqmiCexq5UyTF/ Pxg3V3voL1cYQa7uM0MM8xlYb72IR+VbMDEYnCvqLK9SMtLYvwTZuVVnyQhhXO19G6cL Ih55fv+UOMgo6DwOaNmATOw8lObSuoGXrmepMUW3rdRkM4cfig6kPP0iaR2XQG3GCkJ5 BSpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ETqgvEp+BK5IeQcaommUlEe8fKOhJ00KVNdgTbqltH8=; b=1aH2WQUxEIucEubPb66J9P6tdF/wUTz03/g28kCDOTI1UGKd5aYL9TjHBPn4hV9UvE ZJgbLSqvNaY4aohZS4fC1nylQaCcsf464Zvl0uZtVNnx3TLW3CCkA7Zy/KAokG9VtHRS 90lhOPGJyhXW+5Gui2QcKjdpOPXa00bRKkqVUfCfLGwWVRWkXXQZtiPtDv7GOvf44tMQ obDvLH+luunk9va+jff4lsjKj8T6e4XuFGp2ChvU9zYeYyt5SVVv5NKcCG5XCN6GC64s /tXdWXCaorwcHaOx+JplcBJrjYf6fK9g/EMQwzeIUTDaBUBfpdSy02dy/h0tlkjO4LbN nggA== X-Gm-Message-State: AOAM532mVqma78uGv3p2muHZX82CfyVTYANkpooGoberKbszinUoTKMV tNgHD6u5iI/oX9qRjotq1AZGJD/PJpGs2w== X-Received: by 2002:a05:600c:3488:: with SMTP id a8mr2400179wmq.173.1644350941348; Tue, 08 Feb 2022 12:09:01 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id r2sm4098170wmq.24.2022.02.08.12.09.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 12:09:00 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH 4/5] include: Move qemu_[id]cache_* declarations to new qemu/cacheinfo.h Date: Tue, 8 Feb 2022 20:08:55 +0000 Message-Id: <20220208200856.3558249-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208200856.3558249-1-peter.maydell@linaro.org> References: <20220208200856.3558249-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32e (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The qemu_icache_linesize, qemu_icache_linesize_log, qemu_dcache_linesize, and qemu_dcache_linesize_log variables are not used in many files. Move them out of osdep.h to a new qemu/cacheinfo.h, and document them. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- include/qemu/cacheinfo.h | 21 +++++++++++++++++++++ include/qemu/osdep.h | 5 ----- accel/tcg/translate-all.c | 1 + plugins/loader.c | 1 + tcg/region.c | 1 + tcg/tcg.c | 1 + util/atomic64.c | 1 + util/cacheflush.c | 1 + util/cacheinfo.c | 1 + 9 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 include/qemu/cacheinfo.h diff --git a/include/qemu/cacheinfo.h b/include/qemu/cacheinfo.h new file mode 100644 index 00000000000..019a157ea08 --- /dev/null +++ b/include/qemu/cacheinfo.h @@ -0,0 +1,21 @@ +/* + * QEMU host cacheinfo information + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#ifndef QEMU_CACHEINFO_H +#define QEMU_CACHEINFO_H + +/* + * These variables represent our best guess at the host icache and + * dcache sizes, expressed both as the size in bytes and as the + * base-2 log of the size in bytes. They are initialized at startup + * (via an attribute 'constructor' function). + */ +extern int qemu_icache_linesize; +extern int qemu_icache_linesize_log; +extern int qemu_dcache_linesize; +extern int qemu_dcache_linesize_log; + +#endif diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 0715d6b4509..e36f62a254e 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -616,11 +616,6 @@ pid_t qemu_fork(Error **errp); extern uintptr_t qemu_real_host_page_size; extern intptr_t qemu_real_host_page_mask; -extern int qemu_icache_linesize; -extern int qemu_icache_linesize_log; -extern int qemu_dcache_linesize; -extern int qemu_dcache_linesize_log; - /* * After using getopt or getopt_long, if you need to parse another set * of options, then you must reset optind. Unfortunately the way to diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index bd71db59a9a..5971cd53ab9 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -51,6 +51,7 @@ #include "qemu/qemu-print.h" #include "qemu/timer.h" #include "qemu/main-loop.h" +#include "qemu/cacheinfo.h" #include "exec/log.h" #include "sysemu/cpus.h" #include "sysemu/cpu-timers.h" diff --git a/plugins/loader.c b/plugins/loader.c index a4ec2816922..4883b0a1cbc 100644 --- a/plugins/loader.c +++ b/plugins/loader.c @@ -24,6 +24,7 @@ #include "qemu/rcu_queue.h" #include "qemu/qht.h" #include "qemu/bitmap.h" +#include "qemu/cacheinfo.h" #include "qemu/xxhash.h" #include "qemu/plugin.h" #include "hw/core/cpu.h" diff --git a/tcg/region.c b/tcg/region.c index 7b4e65a52e8..72afb357389 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -26,6 +26,7 @@ #include "qemu/units.h" #include "qemu/madvise.h" #include "qemu/mprotect.h" +#include "qemu/cacheinfo.h" #include "qapi/error.h" #include "exec/exec-all.h" #include "tcg/tcg.h" diff --git a/tcg/tcg.c b/tcg/tcg.c index 5d2f0d8b103..528277d1d3c 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -36,6 +36,7 @@ #include "qemu/qemu-print.h" #include "qemu/timer.h" #include "qemu/cacheflush.h" +#include "qemu/cacheinfo.h" /* Note: the long term plan is to reduce the dependencies on the QEMU CPU definitions. Currently they are used for qemu_ld/st diff --git a/util/atomic64.c b/util/atomic64.c index 93037d5b116..db2c7f0fd0e 100644 --- a/util/atomic64.c +++ b/util/atomic64.c @@ -7,6 +7,7 @@ #include "qemu/osdep.h" #include "qemu/atomic.h" #include "qemu/thread.h" +#include "qemu/cacehinfo.h" #ifdef CONFIG_ATOMIC64 #error This file must only be compiled if !CONFIG_ATOMIC64 diff --git a/util/cacheflush.c b/util/cacheflush.c index 933355b0c99..4b57186d89c 100644 --- a/util/cacheflush.c +++ b/util/cacheflush.c @@ -7,6 +7,7 @@ #include "qemu/osdep.h" #include "qemu/cacheflush.h" +#include "qemu/cacheinfo.h" #include "qemu/bitops.h" diff --git a/util/cacheinfo.c b/util/cacheinfo.c index b182f0b6936..ab1644d490f 100644 --- a/util/cacheinfo.c +++ b/util/cacheinfo.c @@ -9,6 +9,7 @@ #include "qemu/osdep.h" #include "qemu/host-utils.h" #include "qemu/atomic.h" +#include "qemu/cacheinfo.h" int qemu_icache_linesize = 0; int qemu_icache_linesize_log; From patchwork Tue Feb 8 20:08:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 540805 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp791756imo; Tue, 8 Feb 2022 12:34:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4BnnFmG5KRRbRMozpIWOg1zbFWAMfxpRvmPxhOKAa1sRffuWZ7wvdYCyhbO364FKklLlN X-Received: by 2002:a0d:d084:: with SMTP id s126mr6490973ywd.284.1644352460722; Tue, 08 Feb 2022 12:34:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644352460; cv=none; d=google.com; s=arc-20160816; b=cp7X+g+2q8vQ6Kg0C5Sgp+9eP8qnt5MS3qH7Mifmbxh1Pr25060mVBLK+uqG6toi/x KlqGoQy6lpDMCKrR3rN2VUBJF+m18E/QYwTYKLNWQkmpwzkMKu2TJZEJh11qQnmRgSo2 rka0rz44FS7NnmhAbPWbLuztTarMv408tz7YwfHKiODNJYJtkpirmcD51wZga6jX/t3g rAy7th6wn2ZElfiQ/EhH4eSflsKOb+xCvG6mTVBgQZB/lMbeodPK+FDo0Q1Tepeem37z GrimWvTM8Bp8w3bsl3deDqRjyrH6IyFdPcyxCUHPfsOtodiBxGSrmT1fW/vovXhfg/Fu X3vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=D31fWlApiNdJKj9pWF83rHnBapTQ9Q4E45VDFHt714s=; b=w2QvrPfhHYKb0OprRjVfY9b2PKThLFS3hmJx+cCM02aXM0ysKbSs6axPSu8+DxevPB 99TufRMgq9SaJDhH6qJG/OdQGSiHLrolfl49n7Ja0Jmoggnc2uRpPaV4MKG927aMblVr 9rbOJ4M6zDGZmcEG8wp6RSrklomD0tLKwhZLnNoUhXXRCqD+tvxh0hi2/w8O19sbNnQe zxJjuISlL+1ZugLuAQeVa1M1oZKKCJiWHCrLdOI98aOjprhCRt6+pz3csPa2DfV7NISo HdL5hxzHXfWNllhf/F6thk/wii5YwH17XFh5yAvio/yGaxyEdZwRnq6S2xUT2CoLkkxE sb9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bGpHLsp+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x189si365372ybe.233.2022.02.08.12.34.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Feb 2022 12:34:20 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bGpHLsp+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHXBs-0007SS-3T for patch@linaro.org; Tue, 08 Feb 2022 15:34:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHWna-00033C-5t for qemu-devel@nongnu.org; Tue, 08 Feb 2022 15:09:18 -0500 Received: from [2a00:1450:4864:20::336] (port=51049 helo=mail-wm1-x336.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHWnT-00066o-3y for qemu-devel@nongnu.org; Tue, 08 Feb 2022 15:09:12 -0500 Received: by mail-wm1-x336.google.com with SMTP id m26so87662wms.0 for ; Tue, 08 Feb 2022 12:09:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=D31fWlApiNdJKj9pWF83rHnBapTQ9Q4E45VDFHt714s=; b=bGpHLsp+PvLEoDTGev5zrlJZ2jVx0RLw7r85mieSasWgGYUlL+goHvW+mC/gWUuljc 1L4Skdq7GNw6/DfYcTX/mV4yCJFQ4YQIbMWStMB0w0GUGfy+3glkAjHndnAKctVxPHqO 7iCZ2UR1LnlVSSzcvBQVOb5rrFs/l3eZnonmXkDlod89+DmP6Us/2l72JgCkv1OPklkI KbLUFBZi76t0t58RcRM9pfS+KZDDo5/2gENs9fipLqEwVOl6mYMwznL8xm7yoUiEbLBN c26yvHCH6tFFPW6wEQD7DwBH+91C1UndBsD1CCetk22pVLdkLMpAzkiJPMt+21DgPG4f c03w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=D31fWlApiNdJKj9pWF83rHnBapTQ9Q4E45VDFHt714s=; b=w3qlj1Qf8bk85wHfQf02ghT5ZZlKcu3cyF0tJSudLVFKKtSFCpuZecpE/gZGb0lOaw GFzJzHkqay9zx33sOXQ1zPigUOwkeiq0IdHSMWOD02Ve/uYxowscgtoIJLiJpYAlTKX8 Eewjwku4MIhI1zRiuFPmexneTtQbhdKnrkz3KlzGUGEDT4WZDZ+cvx1tRkdVHrfsV6d0 J5zPUuN/e7+GtNHXYLiMyDjIOSCxKibNugO8B6hfUN6I/mkMHZPlg3asZ4/J+siJE/gB Qms505Dc3MmrDXlRyOoHhQvrdRDboroo/m+giesFL6ChxicK8bzYGQBp0xBEcKpKuE2Z 2OHA== X-Gm-Message-State: AOAM530DjLxKkJa9tGQVMU5ELxVa8UZKwEK6wmJNqD0CrZ1x+4I8zmYs pOj5oWCFi4iu4bvVj3i1nlTovK5VBdXiqQ== X-Received: by 2002:a05:600c:ac6:: with SMTP id c6mr2456726wmr.65.1644350942010; Tue, 08 Feb 2022 12:09:02 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id r2sm4098170wmq.24.2022.02.08.12.09.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 12:09:01 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH 5/5] include: Move hardware version declarations to new qemu/hw-version.h Date: Tue, 8 Feb 2022 20:08:56 +0000 Message-Id: <20220208200856.3558249-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208200856.3558249-1-peter.maydell@linaro.org> References: <20220208200856.3558249-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::336 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The "hardware version" machinery (qemu_set_hw_version(), qemu_hw_version(), and the QEMU_HW_VERSION define) is used by fewer than 10 files. Move it out from osdep.h into a new qemu/hw-version.h. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- include/qemu/hw-version.h | 27 +++++++++++++++++++++++++++ include/qemu/osdep.h | 16 ---------------- hw/arm/nseries.c | 1 + hw/ide/core.c | 1 + hw/scsi/megasas.c | 1 + hw/scsi/scsi-bus.c | 1 + hw/scsi/scsi-disk.c | 1 + softmmu/vl.c | 1 + target/i386/cpu.c | 1 + target/s390x/cpu_models.c | 1 + util/osdep.c | 1 + 11 files changed, 36 insertions(+), 16 deletions(-) create mode 100644 include/qemu/hw-version.h diff --git a/include/qemu/hw-version.h b/include/qemu/hw-version.h new file mode 100644 index 00000000000..730a8c904d9 --- /dev/null +++ b/include/qemu/hw-version.h @@ -0,0 +1,27 @@ +/* + * QEMU "hardware version" machinery + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#ifndef QEMU_HW_VERSION_H +#define QEMU_HW_VERSION_H + +/* + * Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default + * instead of QEMU_VERSION, so setting hw_version on MachineClass + * is no longer mandatory. + * + * Do NOT change this string, or it will break compatibility on all + * machine classes that don't set hw_version. + */ +#define QEMU_HW_VERSION "2.5+" + +/* QEMU "hardware version" setting. Used to replace code that exposed + * QEMU_VERSION to guests in the past and need to keep compatibility. + * Do not use qemu_hw_version() in new code. + */ +void qemu_set_hw_version(const char *); +const char *qemu_hw_version(void); + +#endif diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index e36f62a254e..650ba1aa505 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -534,22 +534,6 @@ static inline void qemu_timersub(const struct timeval *val1, void qemu_set_cloexec(int fd); -/* Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default - * instead of QEMU_VERSION, so setting hw_version on MachineClass - * is no longer mandatory. - * - * Do NOT change this string, or it will break compatibility on all - * machine classes that don't set hw_version. - */ -#define QEMU_HW_VERSION "2.5+" - -/* QEMU "hardware version" setting. Used to replace code that exposed - * QEMU_VERSION to guests in the past and need to keep compatibility. - * Do not use qemu_hw_version() in new code. - */ -void qemu_set_hw_version(const char *); -const char *qemu_hw_version(void); - void fips_set_state(bool requested); bool fips_get_state(void); diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c index af3164c5519..9c1cafae86b 100644 --- a/hw/arm/nseries.c +++ b/hw/arm/nseries.c @@ -24,6 +24,7 @@ #include "chardev/char.h" #include "qemu/cutils.h" #include "qemu/bswap.h" +#include "qemu/hw-version.h" #include "sysemu/reset.h" #include "sysemu/runstate.h" #include "sysemu/sysemu.h" diff --git a/hw/ide/core.c b/hw/ide/core.c index e28f8aad611..33463d9b8f2 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -29,6 +29,7 @@ #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/timer.h" +#include "qemu/hw-version.h" #include "sysemu/sysemu.h" #include "sysemu/blockdev.h" #include "sysemu/dma.h" diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index cd43945827c..d5dfb412bac 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -28,6 +28,7 @@ #include "hw/pci/msix.h" #include "qemu/iov.h" #include "qemu/module.h" +#include "qemu/hw-version.h" #include "hw/scsi/scsi.h" #include "scsi/constants.h" #include "trace.h" diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 4057e04ce89..b2e2bc3c96c 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -3,6 +3,7 @@ #include "qemu/error-report.h" #include "qemu/module.h" #include "qemu/option.h" +#include "qemu/hw-version.h" #include "hw/qdev-properties.h" #include "hw/scsi/scsi.h" #include "migration/qemu-file-types.h" diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 9c0dc7b9468..3666b8d9468 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -25,6 +25,7 @@ #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/module.h" +#include "qemu/hw-version.h" #include "hw/scsi/scsi.h" #include "migration/qemu-file-types.h" #include "migration/vmstate.h" diff --git a/softmmu/vl.c b/softmmu/vl.c index 5e1b35ba489..1fe028800fd 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -36,6 +36,7 @@ #include "qemu-version.h" #include "qemu/cutils.h" #include "qemu/help_option.h" +#include "qemu/hw-version.h" #include "qemu/uuid.h" #include "sysemu/reset.h" #include "sysemu/runstate.h" diff --git a/target/i386/cpu.c b/target/i386/cpu.c index aa9e6368004..c9954df4a74 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -21,6 +21,7 @@ #include "qemu/units.h" #include "qemu/cutils.h" #include "qemu/qemu-print.h" +#include "qemu/hw-version.h" #include "cpu.h" #include "tcg/helper-tcg.h" #include "sysemu/reset.h" diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 11e06cc51fa..17ae771939b 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -19,6 +19,7 @@ #include "qapi/error.h" #include "qapi/visitor.h" #include "qemu/module.h" +#include "qemu/hw-version.h" #include "qemu/qemu-print.h" #ifndef CONFIG_USER_ONLY #include "sysemu/sysemu.h" diff --git a/util/osdep.c b/util/osdep.c index 72b678ca2e3..7c4deda6feb 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -39,6 +39,7 @@ extern int madvise(char *, size_t, int); #include "qemu/error-report.h" #include "qemu/madvise.h" #include "qemu/mprotect.h" +#include "qemu/hw-version.h" #include "monitor/monitor.h" static bool fips_enabled = false;