From patchwork Tue Oct 10 00:55:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115324 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3175473qgn; Mon, 9 Oct 2017 18:09:24 -0700 (PDT) X-Received: by 10.55.150.69 with SMTP id y66mr12118770qkd.28.1507597764035; Mon, 09 Oct 2017 18:09:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507597764; cv=none; d=google.com; s=arc-20160816; b=PQy0BEr3OQPlwEZSjFEjGCA5o4s+OhwgEz4DV0+kKfQEgUYn0d0fa20E6HAd7XhEw4 e9av3lHIGySuiKR8g43dTvoUy1gFoe1BS45CTLpzP6T2ssos7m7kH2cq/ev/WBMyvVbV H3fzUCHXSx+HezhVfmAghxLgHIKRYKR8Ln6JaD0tNplYhJMdabLJfl1IyN+/K4HlBOBa jlGYqF59GremqveHAyf78bScdk/ZCJFHGl6rS4N9ru3DfvLVCSJ/CXJZY15jzl7YFtBK MW/OpL82innK7IpfLqbRjvU/8vtjQli6gpAWsiOFvHDkOn43yEeofqB3BIW9GrjfbX20 QjDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=LEPSQBFcHMdI/3CokXPsBH3v71WBctmmqRbtmcTyRnc=; b=lnJEtVzxEw4wNhHbjTulWsi8+dWEVznj1I9R89NC/MGencKtSvnthf9bYKPmjahfqQ 2srK8qfiaovF7/pFC0zy+djv6Tvdy04N93yoW27EJQMPlTpOrhUOmBO41CA4cKwuQE1R My/pMF25RWDxTiINrYGFEhP3fxGAoIrpxfgOVtWiCKiPNQSUP6bWFS4IAjnbri+iYrIi bpFrXo7KtEqSq0feg8ZqzNHUh5i38GM2qIdEgJG2Y9RyFd/5E7xyl2ah2rBC+ox0ZOtX HS7WcY9NsesThztsRLQLeQoXeOtjZorvGiZD3qI4zNwgMo+hQLBYg/Trgc9X7wH4R87B F3LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WQLCa5OO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l38si1481055qtl.0.2017.10.09.18.09.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 09 Oct 2017 18:09:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WQLCa5OO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1j2v-0003mG-W8 for patch@linaro.org; Mon, 09 Oct 2017 21:09:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1iqU-0002Su-9F for qemu-devel@nongnu.org; Mon, 09 Oct 2017 20:56:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1iqT-0004Zg-8W for qemu-devel@nongnu.org; Mon, 09 Oct 2017 20:56:30 -0400 Received: from mail-pf0-x235.google.com ([2607:f8b0:400e:c00::235]:54345) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e1iqT-0004ZL-1o for qemu-devel@nongnu.org; Mon, 09 Oct 2017 20:56:29 -0400 Received: by mail-pf0-x235.google.com with SMTP id m28so10542062pfi.11 for ; Mon, 09 Oct 2017 17:56:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LEPSQBFcHMdI/3CokXPsBH3v71WBctmmqRbtmcTyRnc=; b=WQLCa5OO6AMfL1N8P81y/5OglHoVjpVrDeOCeA395OJ0/1q4gpC9UWBH/dpXs01KLu jULxX+BRHx92lGHbFN3nEpqkbm5wTYj6O5f58Aqg5bndPQp9QXrRm+8Dc4Hp6eL6jOpr MHAvyWQpDTt+yffZn2yfj+g1dNpZX7FCiYjfU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LEPSQBFcHMdI/3CokXPsBH3v71WBctmmqRbtmcTyRnc=; b=QOVvu0vP+J3QAnH42EKw6cVPdDxQrQv3tIstta4HN0VosxbvcKMvJHhbAuXbX4hsTj /l8Hh9JCITnqrGEnw3jUXGzZ3tO/xIwy++yTMWkP6+wDb+IgxKrQrjl83/O+mWnOSzXL Nv0mlGiarh7pyXvs8vyjYXTp5JLv3DlvhgQ6SQcDHp2QT8k4tjllO0AvkHY7mTi6ESyk rC9IMqEgUKzOYO+ieWooB6vVXwwWqPqH4Hrubs5hHbgXs+GixQ0EcwjtFxRkj7E+NvLu pfUNaGB6Rk51iHcC0WoIILLKhXWV0M5qZ6ZF6H3Y+otQJvfJCaPDRqDuKM8AckcT1MeN VnkQ== X-Gm-Message-State: AMCzsaXUKjvIoF9VE8nVD2lBdyjscFkJJic4Xu+NgaNeYw1CltHs9ziA lJFHgbRvsWKi+BD+cDEA9SBlI+T57L4= X-Google-Smtp-Source: AOwi7QBn6Zh859fxupPTQPVYzITiZmk5ethOJAHiCn+VjIL0ZhDuAgHjBWqLP0gKPHezioIwoIfskA== X-Received: by 10.99.63.199 with SMTP id m190mr10278633pga.273.1507596987730; Mon, 09 Oct 2017 17:56:27 -0700 (PDT) Received: from bigtime.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id n19sm17121368pfj.52.2017.10.09.17.56.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Oct 2017 17:56:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 17:55:56 -0700 Message-Id: <20171010005600.28735-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171010005600.28735-1-richard.henderson@linaro.org> References: <20171010005600.28735-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::235 Subject: [Qemu-devel] [PULL 19/23] util: move qemu_real_host_page_size/mask to osdep.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, "Emilio G. Cota" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" These only depend on the host and therefore belong in the common osdep, not in a target-dependent object. While at it, query the host during an init constructor, which guarantees the page size will be well-defined throughout the execution of the program. Suggested-by: Richard Henderson Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 2 -- include/qemu/osdep.h | 6 ++++++ exec.c | 4 ---- util/pagesize.c | 18 ++++++++++++++++++ util/Makefile.objs | 1 + 5 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 util/pagesize.c -- 2.13.6 diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index ffe43d5654..778031c3d7 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -229,8 +229,6 @@ extern int target_page_bits; /* Using intptr_t ensures that qemu_*_page_mask is sign-extended even * when intptr_t is 32-bit and we are aligning a long long. */ -extern uintptr_t qemu_real_host_page_size; -extern intptr_t qemu_real_host_page_mask; extern uintptr_t qemu_host_page_size; extern intptr_t qemu_host_page_mask; diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 9dd318a7dd..826650c58a 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -505,6 +505,12 @@ char *qemu_get_pid_name(pid_t pid); */ pid_t qemu_fork(Error **errp); +/* Using intptr_t ensures that qemu_*_page_mask is sign-extended even + * when intptr_t is 32-bit and we are aligning a long long. + */ +extern uintptr_t qemu_real_host_page_size; +extern intptr_t qemu_real_host_page_mask; + extern int qemu_icache_linesize; extern int qemu_dcache_linesize; diff --git a/exec.c b/exec.c index 7a80460725..6378714a2b 100644 --- a/exec.c +++ b/exec.c @@ -120,8 +120,6 @@ int use_icount; uintptr_t qemu_host_page_size; intptr_t qemu_host_page_mask; -uintptr_t qemu_real_host_page_size; -intptr_t qemu_real_host_page_mask; bool set_preferred_target_page_bits(int bits) { @@ -3606,8 +3604,6 @@ void page_size_init(void) { /* NOTE: we can always suppose that qemu_host_page_size >= TARGET_PAGE_SIZE */ - qemu_real_host_page_size = getpagesize(); - qemu_real_host_page_mask = -(intptr_t)qemu_real_host_page_size; if (qemu_host_page_size == 0) { qemu_host_page_size = qemu_real_host_page_size; } diff --git a/util/pagesize.c b/util/pagesize.c new file mode 100644 index 0000000000..998632cf6e --- /dev/null +++ b/util/pagesize.c @@ -0,0 +1,18 @@ +/* + * pagesize.c - query the host about its page size + * + * Copyright (C) 2017, Emilio G. Cota + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" + +uintptr_t qemu_real_host_page_size; +intptr_t qemu_real_host_page_mask; + +static void __attribute__((constructor)) init_real_host_page_size(void) +{ + qemu_real_host_page_size = getpagesize(); + qemu_real_host_page_mask = -(intptr_t)qemu_real_host_page_size; +} diff --git a/util/Makefile.objs b/util/Makefile.objs index 50a55ecc75..2973b0a323 100644 --- a/util/Makefile.objs +++ b/util/Makefile.objs @@ -40,6 +40,7 @@ util-obj-y += buffer.o util-obj-y += timed-average.o util-obj-y += base64.o util-obj-y += log.o +util-obj-y += pagesize.o util-obj-y += qdist.o util-obj-y += qht.o util-obj-y += range.o