From patchwork Tue Oct 10 19:30:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115461 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4122892qgn; Tue, 10 Oct 2017 12:41:10 -0700 (PDT) X-Received: by 10.200.3.14 with SMTP id q14mr21771519qtg.336.1507664470747; Tue, 10 Oct 2017 12:41:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507664470; cv=none; d=google.com; s=arc-20160816; b=jx4HXIWVyFmJMzfE3FuMwDhEwLhpTgteviJ4kIgVwZQnDB7/v22f7iPhHr6wtsgpdV vTNWj9aPgGKF2gWScM3M9JiCWrF2+KZg0faiAubF/9/Df0VcDcWP0RpT9Vfi15y2uZNi 5rRmIEQrN8UyChGmjdbR9SyD+tb3Q0ZhsglcCS8LVJLj7v2lbr9mfYlwXWL+PfyWN5dC +3jl3QvDoCJ97DqsYVGoexQyyWclFmAS+R1JGSmt3rXs7aZXpMJVoQkvwxZZwvVFoo2K 1geL/6vi2QYHqHT0VJuubPq5Nhf0kh6LhKVvntK1ybGUPhVxau975/712w4/htWC1ElC fs8Q== 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=PN6dHLpLeEOBPOooffvjUAKNbnv5op/NNpZDtoaPGxTABK7s1x2ZzDzKy1RoYao0EF W9AsMtcwAHbRPKpGrvGH2UBuFvUuLkCzAH/lfdVU3x5WqKg7kkh4FQ4QOhX80R8QpIjZ zBs8jzQlMIk0rim7u4znQF8UjVQksTf2V1OiLhf0HOrE3sAOIyQs6qQEXlhSEsNy8pSZ FLVcE81FSxyXcypbiuqw+psVi5cn9SAzyHP4el4GhEvVlNpRQWegHLoO7tXbXHhbECtI LzKRQQxXKKhz+6EghoDVIpospaMD7KREfM7M//VqqQZTv6f1IfisVZvDYJZi9wikWQpz mltA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NC3KgIhp; 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 l40si1630126qtf.189.2017.10.10.12.41.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 10 Oct 2017 12:41:10 -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=NC3KgIhp; 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]:36843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e20Oq-0000DP-J2 for patch@linaro.org; Tue, 10 Oct 2017 15:41:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58954) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e20Eb-0000pb-WB for qemu-devel@nongnu.org; Tue, 10 Oct 2017 15:30:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e20EZ-000583-OB for qemu-devel@nongnu.org; Tue, 10 Oct 2017 15:30:33 -0400 Received: from mail-pf0-x22e.google.com ([2607:f8b0:400e:c00::22e]:55365) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e20EZ-00057k-J5 for qemu-devel@nongnu.org; Tue, 10 Oct 2017 15:30:31 -0400 Received: by mail-pf0-x22e.google.com with SMTP id 17so9937919pfn.12 for ; Tue, 10 Oct 2017 12:30:31 -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=NC3KgIhp8LlhYrA/JvUGJtCd6e3p6X9N1PnVzaYQ2kPXOdgy+92bTaNbXzSonebcyi XuGnWi/EnArQzTUji0w62L/GziO18k+4vp0nQGzSmzADNdbaBObVra0CjZXsFHnnPOXd oZz36c/njuiUul/3zcuv0O266KeuPtKm+eKuY= 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=J4mL72GyCkiESZbbq8WY2W4ii48xq70Mzpz+1sjBn9d81euKbsx2C36jushfNV/GDK Xb/uXo02+09neVWmmjfKD3pRCj/zWB6ms1wGEWTpb4vhSpMeOMz+72SVqDVI70YA0xZz asGCXhkDWw7KBNzvR0AgG1BXeywR2sQWNPaEAC2xu7ERLkiq3J3dt1oBW+k3fB784Dxh nqjiLTzDIWSxC0JZLrpV+MiTlTfkbCeF+nvccIE8z/9TBp36Z//QUOp3DyK6ZgnbKGdj RPXn0IU86D8d4xilZPrRzvYPJIMvhMSf3/3EHakE59TKNAbMDafpPMiB8mJIJgBGI/oK N67A== X-Gm-Message-State: AMCzsaUBkdeXJBGiL02MBhb75R9BjJk0T1/8rRUDgOK04/qurTjWt6li bAa8XlIV64Eh7a7HiuoIL9TIi8EH4mM= X-Google-Smtp-Source: AOwi7QC5fqbLvFNbZJkWm9uzkrbPKcp4jkEg7vsgz983Elky6IctE5uZazkAKJqHbYrzi6VWvoH7bQ== X-Received: by 10.98.31.73 with SMTP id f70mr14276179pff.183.1507663830341; Tue, 10 Oct 2017 12:30:30 -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 r22sm19859788pfl.15.2017.10.10.12.30.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Oct 2017 12:30:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 10 Oct 2017 12:30:01 -0700 Message-Id: <20171010193003.28857-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171010193003.28857-1-richard.henderson@linaro.org> References: <20171010193003.28857-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::22e Subject: [Qemu-devel] [PULL v2 18/20] 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