From patchwork Wed Oct 23 15:44:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1182306 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="K3Y/xAHu"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46yxCx2bVNz9sNx for ; Thu, 24 Oct 2019 03:48:59 +1100 (AEDT) Received: from localhost ([::1]:41588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNJod-0000o8-Rj for incoming@patchwork.ozlabs.org; Wed, 23 Oct 2019 12:48:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42496) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNIp1-0004cO-3T for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNIoz-0005RH-33 for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:14 -0400 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]:46766) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNIox-0005Ki-2p for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:11 -0400 Received: by mail-qt1-x82f.google.com with SMTP id u22so32898232qtq.13 for ; Wed, 23 Oct 2019 08:45:09 -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=VdwoVOQvGjyK5xwO9CwTmTvaoS1oPRDJG2i202FKHeA=; b=K3Y/xAHulnNNkqoZ/f937AsEOym8U2bSpJC+sPBBbW+dYInTBLMUarGjWz/8pd3Fto BqzAZleXOIMYOnW79c2Kk5xoEdMp79nwd9yBk7M5YciIH5SyoviOKAJhyGjmlhUB9hjy g775Gf07wETmxgEuzSCy0j37hpPqANcbYLNQ6fF0QDwV2lyVmcdg8Af2xgR59TphVPSV YAsjidGwfzRGvQ0a7fG/Nbhoic2TMgTpOR530Jhxh3yM6Dbhpq8PsqYnvT8C0us86r4J Pt6akoAzwDHrURwgNGVjt2nRXB5CAwde8XHmjWHl3HIOxiaugQtjBsaV+FY2OsZr/J2T k8jQ== 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=VdwoVOQvGjyK5xwO9CwTmTvaoS1oPRDJG2i202FKHeA=; b=Y1xfFbPY/5QHUH0170WOqpJ3joNow5+xINe/2gbhqokSLzX+pligL4MI1LaX7l/E8T 3nJ0rFYV0fTddCtHWyFswMyY8l9S4ckqSMf/+7kKBagoRkYfUaNkcfPoUGBTbUhaTtII 7p+TMrcAaRSCZHeLyStbZuG78w+J5xqGD8GrmPDLhuHG4mPzd+Bnrxq52RUnXYmKW7W6 btHV4gqEnmEgXDf59yT6vXeZ6D5cUu6CL1NvoLfH/03EZNZ++zSIJVAMV89oJyTt/wbs fAxdxvwZ91lVfNvn8e+gbDjhFxuN4LkjY4pcR9gZlqXMP6p0fpeVZsKKZVATlV7MVBTh XPuQ== X-Gm-Message-State: APjAAAWHlA2xL4YtKegi7uuJ8tVcE54euWajZLkOoqTTgt4lpYVtwY72 EreyKb1c+d89ovLEh/Qq1nKcViiiwVY= X-Google-Smtp-Source: APXvYqzRWKfHdcLWb0b285JXTRO/5Zi7ypt4kW927Gpob4oTKwjRFeyOkes6JX1ttBU5zswG6e1uGA== X-Received: by 2002:a05:6214:1ca:: with SMTP id c10mr5266708qvt.233.1571845508689; Wed, 23 Oct 2019 08:45:08 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-50.nyc.biz.rr.com. [172.254.253.50]) by smtp.gmail.com with ESMTPSA id o1sm2456272qtb.82.2019.10.23.08.45.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 08:45:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 1/7] cpu: use ROUND_UP() to define xxx_PAGE_ALIGN Date: Wed, 23 Oct 2019 11:44:59 -0400 Message-Id: <20191023154505.30521-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023154505.30521-1-richard.henderson@linaro.org> References: <20191023154505.30521-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::82f X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, alex.bennee@linaro.org, Wei Yang Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Wei Yang Use ROUND_UP() to define, which is a little bit easy to read. Reviewed-by: Michael S. Tsirkin Reviewed-by: David Gibson Reviewed-by: David Gibson Reviewed-by: Juan Quintela Signed-off-by: Wei Yang Message-Id: <20191013021145.16011-2-richardw.yang@linux.intel.com> Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index ad9ab85eb3..255bb186ac 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -220,7 +220,7 @@ extern int target_page_bits; #define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) #define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1) -#define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) +#define TARGET_PAGE_ALIGN(addr) ROUND_UP((addr), TARGET_PAGE_SIZE) /* 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. @@ -228,9 +228,8 @@ extern int target_page_bits; extern uintptr_t qemu_host_page_size; extern intptr_t qemu_host_page_mask; -#define HOST_PAGE_ALIGN(addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask) -#define REAL_HOST_PAGE_ALIGN(addr) (((addr) + qemu_real_host_page_size - 1) & \ - qemu_real_host_page_mask) +#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size) +#define REAL_HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_real_host_page_size) /* same as PROT_xxx */ #define PAGE_READ 0x0001 From patchwork Wed Oct 23 15:45:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1182313 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="DrjcKVqM"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46yxMq5bQmz9sPV for ; Thu, 24 Oct 2019 03:55:51 +1100 (AEDT) Received: from localhost ([::1]:41804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNJvH-0001ox-JI for incoming@patchwork.ozlabs.org; Wed, 23 Oct 2019 12:55:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42527) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNIp3-0004iA-18 for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNIp1-0005VQ-2y for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:16 -0400 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]:38958) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNIoz-0005Nw-3Y for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:15 -0400 Received: by mail-qt1-x843.google.com with SMTP id t8so15415592qtc.6 for ; Wed, 23 Oct 2019 08:45:11 -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 :mime-version:content-transfer-encoding; bh=PzEJPTABzvYPmN/2adJfy5uLdEuaRGm0+mdzHd64cl8=; b=DrjcKVqMKxbcZyq0X/pR2ND36ep6US7cUZWY57k9PsE4RyArSC6l97TFoIIN52WWRs t1NC/LEP+njpM75STy6IiBgWw6/E9R7iYfeVB0viiosCU1H0jgvJiDkJOIspaEGNqwXV h52rrVNW+Wx8t1H8qTSTCgM3/cIXA5Q0+Z/HNdk8SE8z0IPsA9sfUHZTqyB1QIQ0Jka2 LbejPbtmfhQv6jeI6EfLcEeLFpKg9eBdnOIQ1XFDXIcFTi2zS5DhRvdrPS1bzbrRUy4l TW01AS054vW39CBmDTcb/DBYBJYaNf5aggxuFKf3p3MvUUmHRikYnwdmmALhJQvBw7Ev OrYg== 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:mime-version:content-transfer-encoding; bh=PzEJPTABzvYPmN/2adJfy5uLdEuaRGm0+mdzHd64cl8=; b=r81khUpJehhF8wsmftcmBxiHrSWO/gwpfgC6QDOiZ0hQ4afqEhWBt4BQYj7fZdJlBz vHa8efw5l9DcbdYX0trZBoXShqW4aTjN6jUMA+MCwq5mUeVxwF/2h9g60k5zFHAc5JBC ZPExmtYZiIJzPTg2saaU54NSV6fChQCUOBR+VbJvNewitQ9LaED4Z1uWC+onjz4NCgAk 0EMurENAATZJppObpzO2Ps+YwLwUupXxeQHt7kqQWefH0a4xQK3cyDgTKAfW2I978fGC c+VxP7K1zUs/UcFlGTJKXJaOIpcLLe47n/Tm6hyY5uHoAkNeSJYkEAoDsxqNMR3/Pphc T4OQ== X-Gm-Message-State: APjAAAXxoYMRlU6OWZvgF9j7pXpjJ6qhGrPNg0qJRQ3meSqQNciyJvfT cAMBn9cJKorHWuThSFoUhxUaceYLrE0= X-Google-Smtp-Source: APXvYqyo/3SEPMr1inThK2IabmZ4wG9NUE2l4purg4v/UFYveD25eBVmxB0QQofw34Udy65ki6acpw== X-Received: by 2002:ac8:2247:: with SMTP id p7mr10137158qtp.180.1571845510213; Wed, 23 Oct 2019 08:45:10 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-50.nyc.biz.rr.com. [172.254.253.50]) by smtp.gmail.com with ESMTPSA id o1sm2456272qtb.82.2019.10.23.08.45.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 08:45:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 2/7] exec: Split out variable page size support to exec-vary.c Date: Wed, 23 Oct 2019 11:45:00 -0400 Message-Id: <20191023154505.30521-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023154505.30521-1-richard.henderson@linaro.org> References: <20191023154505.30521-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::843 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The next patch will play a trick with "const" that will confuse the compiler about the uses of target_page_bits within exec.c. Moving everything to a new file prevents this confusion. No functional change so far. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- Makefile.target | 2 +- include/qemu-common.h | 6 +++++ exec-vary.c | 57 +++++++++++++++++++++++++++++++++++++++++++ exec.c | 34 -------------------------- 4 files changed, 64 insertions(+), 35 deletions(-) create mode 100644 exec-vary.c diff --git a/Makefile.target b/Makefile.target index 5e916230c4..ca3d14efe1 100644 --- a/Makefile.target +++ b/Makefile.target @@ -107,7 +107,7 @@ obj-y += trace/ ######################################################### # cpu emulator library -obj-y += exec.o +obj-y += exec.o exec-vary.o obj-y += accel/ obj-$(CONFIG_TCG) += tcg/tcg.o tcg/tcg-op.o tcg/tcg-op-vec.o tcg/tcg-op-gvec.o obj-$(CONFIG_TCG) += tcg/tcg-common.o tcg/optimize.o diff --git a/include/qemu-common.h b/include/qemu-common.h index 8d84db90b0..082da59e85 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -74,6 +74,12 @@ void cpu_exec_step_atomic(CPUState *cpu); */ bool set_preferred_target_page_bits(int bits); +/** + * finalize_target_page_bits: + * Commit the final value set by set_preferred_target_page_bits. + */ +void finalize_target_page_bits(void); + /** * Sends a (part of) iovec down a socket, yielding when the socket is full, or * Receives data into a (part of) iovec from a socket, diff --git a/exec-vary.c b/exec-vary.c new file mode 100644 index 0000000000..48c0ab306c --- /dev/null +++ b/exec-vary.c @@ -0,0 +1,57 @@ +/* + * Variable page size handling + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "exec/exec-all.h" + +#ifdef TARGET_PAGE_BITS_VARY +int target_page_bits; +bool target_page_bits_decided; +#endif + +bool set_preferred_target_page_bits(int bits) +{ + /* + * The target page size is the lowest common denominator for all + * the CPUs in the system, so we can only make it smaller, never + * larger. And we can't make it smaller once we've committed to + * a particular size. + */ +#ifdef TARGET_PAGE_BITS_VARY + assert(bits >= TARGET_PAGE_BITS_MIN); + if (target_page_bits == 0 || target_page_bits > bits) { + if (target_page_bits_decided) { + return false; + } + target_page_bits = bits; + } +#endif + return true; +} + +void finalize_target_page_bits(void) +{ +#ifdef TARGET_PAGE_BITS_VARY + if (target_page_bits == 0) { + target_page_bits = TARGET_PAGE_BITS_MIN; + } + target_page_bits_decided = true; +#endif +} diff --git a/exec.c b/exec.c index fb0943cfed..5bf181d23e 100644 --- a/exec.c +++ b/exec.c @@ -91,11 +91,6 @@ AddressSpace address_space_memory; static MemoryRegion io_mem_unassigned; #endif -#ifdef TARGET_PAGE_BITS_VARY -int target_page_bits; -bool target_page_bits_decided; -#endif - CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus); /* current CPU in the current thread. It is only valid inside @@ -109,37 +104,8 @@ int use_icount; uintptr_t qemu_host_page_size; intptr_t qemu_host_page_mask; -bool set_preferred_target_page_bits(int bits) -{ - /* The target page size is the lowest common denominator for all - * the CPUs in the system, so we can only make it smaller, never - * larger. And we can't make it smaller once we've committed to - * a particular size. - */ -#ifdef TARGET_PAGE_BITS_VARY - assert(bits >= TARGET_PAGE_BITS_MIN); - if (target_page_bits == 0 || target_page_bits > bits) { - if (target_page_bits_decided) { - return false; - } - target_page_bits = bits; - } -#endif - return true; -} - #if !defined(CONFIG_USER_ONLY) -static void finalize_target_page_bits(void) -{ -#ifdef TARGET_PAGE_BITS_VARY - if (target_page_bits == 0) { - target_page_bits = TARGET_PAGE_BITS_MIN; - } - target_page_bits_decided = true; -#endif -} - typedef struct PhysPageEntry PhysPageEntry; struct PhysPageEntry { From patchwork Wed Oct 23 15:45:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1182309 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="C9frGU0A"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46yxJ95DtKz9sNx for ; Thu, 24 Oct 2019 03:52:41 +1100 (AEDT) Received: from localhost ([::1]:41694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNJsE-0005nj-O1 for incoming@patchwork.ozlabs.org; Wed, 23 Oct 2019 12:52:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42528) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNIp3-0004iF-16 for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNIp1-0005Ws-Nx for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:16 -0400 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]:34108) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNIp0-0005Pr-W2 for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:15 -0400 Received: by mail-qt1-x833.google.com with SMTP id e14so13184339qto.1 for ; Wed, 23 Oct 2019 08:45:12 -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=/AKbLHXTnM8m/9emDbjfL8Myv0gqqIqdV5s6THzE+7U=; b=C9frGU0AzZ7BnyrHTHH9SfZnuJGxFsRol9ai81q7DPmj+TZAlXLm2UZJm1RyH591z4 uGtpGcZmP3LxSQZk4vwhzXR2j3m14aMX9C4R7o6pFultK4PKS1mFHKpThXsaobnmb7kb fYBS4sU9N+CPR45APZke8b9i+cfu3Ox4akvLQlzMfbVk/qcp5+wqdK3y1gCh4VQ0ax3c jvf5pUy/0suRMmJqADyg7MYg5hHKroeOp33XJocDZ8eSNz0kFUbHPWppmeHtjV4VYpxd 5keHgySgfUuS0Xc/RL45RzxkxoHC8LQohSYw2thj96dFav8KvCPv2PtkbGJqsXN4ivAp uLxQ== 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=/AKbLHXTnM8m/9emDbjfL8Myv0gqqIqdV5s6THzE+7U=; b=OlUbLE5fshO9Xpy8qf6kQQ7N6VEYBxFMzSY4h1vrNoQEsl3Tkyj9zBlrQzZSRT/Fa0 tpYx0ZSsRbUohfj0/juwxGeCqIx8bvxFTTUhg/iSyFsbmg944sLyHm/hN2WbWIPdpNLq /VwUNIB/iMBHOEPWjmhkIPBaj4GGbu3N33zgpUslx68GUJKGP5x035WE6VVOSdHkmc91 FilnK4t86HPTtx+u0TkJxWucxECGW48ECVHi1rMbgyue7rV36qKx20lPFD6PGMXCZsIh YVT9sE3o4kSsAcamkVSmxjUiZmpED3DH0pQRLcj0uXzyXEPUKWOE5W+wt+NYkdJkz07+ M7vA== X-Gm-Message-State: APjAAAW9xyRjoSWnrBYqRZuZBCHWNlN61APpL34rsQ1K4YEYmVH9ps1l ECeQKiLxjIVr9/xFoCdSwmHf7ZG0QrY= X-Google-Smtp-Source: APXvYqyVks026fWC02gOchDmwaZKGKv5LNjSigxBXb9gMxFgvtwYNxLXjuq1jTL0I5PdtBZgEXRopQ== X-Received: by 2002:aed:3225:: with SMTP id y34mr9955341qtd.353.1571845511156; Wed, 23 Oct 2019 08:45:11 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-50.nyc.biz.rr.com. [172.254.253.50]) by smtp.gmail.com with ESMTPSA id o1sm2456272qtb.82.2019.10.23.08.45.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 08:45:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 3/7] configure: Detect compiler support for __attribute__((alias)) Date: Wed, 23 Oct 2019 11:45:01 -0400 Message-Id: <20191023154505.30521-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023154505.30521-1-richard.henderson@linaro.org> References: <20191023154505.30521-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::833 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Such support is present almost everywhere, except for Xcode 9. It is added in Xcode 10, but travis uses xcode9 by default, so we should support it for a while yet. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- configure | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/configure b/configure index 145fcabbb3..3a9862fe5e 100755 --- a/configure +++ b/configure @@ -5518,6 +5518,21 @@ if compile_prog "" "" ; then vector16=yes fi +######################################## +# See if __attribute__((alias)) is supported. +# This false for Xcode 9, but has been remedied for Xcode 10. +# Unfortunately, travis uses Xcode 9 by default. + +attralias=no +cat > $TMPC << EOF +int x = 1; +extern const int y __attribute__((alias("x"))); +int main(void) { return 0; } +EOF +if compile_prog "" "" ; then + attralias=yes +fi + ######################################## # check if getauxval is available. @@ -7083,6 +7098,10 @@ if test "$vector16" = "yes" ; then echo "CONFIG_VECTOR16=y" >> $config_host_mak fi +if test "$attralias" = "yes" ; then + echo "CONFIG_ATTRIBUTE_ALIAS=y" >> $config_host_mak +fi + if test "$getauxval" = "yes" ; then echo "CONFIG_GETAUXVAL=y" >> $config_host_mak fi From patchwork Wed Oct 23 15:45:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1182317 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="aEmAmX23"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46yxZL34QRz9sP4 for ; Thu, 24 Oct 2019 04:04:57 +1100 (AEDT) Received: from localhost ([::1]:41926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNK46-0001yT-UN for incoming@patchwork.ozlabs.org; Wed, 23 Oct 2019 13:04:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42577) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNIp4-0004mb-PT for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNIp2-0005Z8-Un for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:18 -0400 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]:42859) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNIp1-0005R8-1L for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:15 -0400 Received: by mail-qt1-x843.google.com with SMTP id w14so32933492qto.9 for ; Wed, 23 Oct 2019 08:45:13 -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=GvLqP4YBrj+nrlStAyuwbfcMGIRPPiTu+vJ+23TQgAw=; b=aEmAmX23InlnUT2icHg3aEvWcd49dzoz4tbuKp+wnSiTzBvcUrDLYrPrMHv9kwvBoR b9WlmgYjlZNXvCaej6FvgZSEcjkfVLvTg0I2djVAFWAo0wCkqt0x/I/MGRu5n0mKdczy EgPCoqsGfSzTt6VKsxkEkJndlPDk6k+3KNgacLCS2Ybu495vzIGN4JYK05cRLjoQZ76+ cNKnvW5Q21wIaLH1lFYI589K+Sx2g3Eq9EJ68KivWEP/s/pI9xrm6vTjbjMKjlnm7zjK G/5Nh2kpQH5y7DvVUzICh0Vt4VXFkQV0U2P63J1fm3dAzE8v/SkuOHN0HXK/YHErMhkM vuug== 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=GvLqP4YBrj+nrlStAyuwbfcMGIRPPiTu+vJ+23TQgAw=; b=bsiBlAs5Cc30BerFvt6cBckN5g5tX5K61GIRRkUDZAxC4GCXk9wW+IsujyEOIkSvU/ WfNSplOqd1SHGK5u+AxAYZvyn43sPN+Vw+dY57VCxxThbSI2o9kWc0VnZ18wIIJXTrw+ E/y66wF4tO1NSfsL8SJmOF+BEW13bsdhgc1mc4tvsqZmm19j6QzdxUZU1XrCvu33UDiv nv0Va0ntohc8F2iNSq/YM2nJycx5iKmDCZ4cnGGJ2k8KHqzPVsDNQgQxLrYE2kJHLQlI cnPwvULRxcpHnKjinb77md85PFRnj6ST51M8V9toFHatcFT9fxORhu4RHD8vqVAl0UWT ltnw== X-Gm-Message-State: APjAAAVIWCbhcTswvbxCXC/zL6hqs4Xc4fnK+iXDbAuBqNXO1x5F/ROr lxmPEcM6XDWjaw7d+8MnzrksswKVnZk= X-Google-Smtp-Source: APXvYqzPMQXqII0RIFiLAvVcq6huIg3ZdYpjVAcAQydEIsP9Juw2FS79y0dcZR3YvaOHq2B9IG9zyA== X-Received: by 2002:aed:2687:: with SMTP id q7mr9746711qtd.382.1571845512179; Wed, 23 Oct 2019 08:45:12 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-50.nyc.biz.rr.com. [172.254.253.50]) by smtp.gmail.com with ESMTPSA id o1sm2456272qtb.82.2019.10.23.08.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 08:45:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 4/7] exec: Use const alias for TARGET_PAGE_BITS_VARY Date: Wed, 23 Oct 2019 11:45:02 -0400 Message-Id: <20191023154505.30521-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023154505.30521-1-richard.henderson@linaro.org> References: <20191023154505.30521-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::843 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Using a variable that is declared "const" for this tells the compiler that it may read the value once and assume that it does not change across function calls. For target_page_size, this means we have only one assert per function, and one read of the variable. This reduces the size of qemu-system-aarch64 by 8k. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- v2: Notice CONFIG_ATTRIBUTE_ALIAS, and work around Xcode 9 lossage. --- include/exec/cpu-all.h | 14 +++++++--- exec-vary.c | 60 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 62 insertions(+), 12 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 255bb186ac..76515dc8d9 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -210,10 +210,16 @@ static inline void stl_phys_notdirty(AddressSpace *as, hwaddr addr, uint32_t val /* page related stuff */ #ifdef TARGET_PAGE_BITS_VARY -extern bool target_page_bits_decided; -extern int target_page_bits; -#define TARGET_PAGE_BITS ({ assert(target_page_bits_decided); \ - target_page_bits; }) +typedef struct { + bool decided; + int bits; +} TargetPageBits; +# if defined(CONFIG_ATTRIBUTE_ALIAS) || !defined(IN_EXEC_VARY) +extern const TargetPageBits target_page; +#else +extern TargetPageBits target_page; +# endif +#define TARGET_PAGE_BITS (assert(target_page.decided), target_page.bits) #else #define TARGET_PAGE_BITS_MIN TARGET_PAGE_BITS #endif diff --git a/exec-vary.c b/exec-vary.c index 48c0ab306c..e0befd502a 100644 --- a/exec-vary.c +++ b/exec-vary.c @@ -19,11 +19,55 @@ #include "qemu/osdep.h" #include "qemu-common.h" + +#define IN_EXEC_VARY 1 + #include "exec/exec-all.h" #ifdef TARGET_PAGE_BITS_VARY -int target_page_bits; -bool target_page_bits_decided; +# ifdef CONFIG_ATTRIBUTE_ALIAS +/* + * We want to declare the "target_page" variable as const, which tells + * the compiler that it can cache any value that it reads across calls. + * This avoids multiple assertions and multiple reads within any one user. + * + * This works because we initialize the target_page data very early, in a + * location far removed from the functions that require the final results. + * + * This also requires that we have a non-constant symbol by which we can + * perform the actual initialization, and which forces the data to be + * allocated within writable memory. Thus "init_target_page", and we use + * that symbol exclusively in the two functions that initialize this value. + * + * The "target_page" symbol is created as an alias of "init_target_page". + */ +static TargetPageBits init_target_page; + +/* + * Note that this is *not* a redundant decl, this is the definition of + * the "target_page" symbol. The syntax for this definition requires + * the use of the extern keyword. This seems to be a GCC bug in + * either the syntax for the alias attribute or in -Wredundant-decls. + * + * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91765 + */ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wredundant-decls" + +extern const TargetPageBits target_page + __attribute__((alias("init_target_page"))); + +# pragma GCC diagnostic pop +# else +/* + * When aliases are not supported then we force two different declarations, + * by way of suppressing the header declaration with IN_EXEC_VARY. + * We assume that on such an old compiler, LTO cannot be used, and so the + * compiler cannot not detect the mismatched declarations, and all is well. + */ +TargetPageBits target_page; +# define init_target_page target_page +# endif #endif bool set_preferred_target_page_bits(int bits) @@ -36,11 +80,11 @@ bool set_preferred_target_page_bits(int bits) */ #ifdef TARGET_PAGE_BITS_VARY assert(bits >= TARGET_PAGE_BITS_MIN); - if (target_page_bits == 0 || target_page_bits > bits) { - if (target_page_bits_decided) { + if (init_target_page.bits == 0 || init_target_page.bits > bits) { + if (init_target_page.decided) { return false; } - target_page_bits = bits; + init_target_page.bits = bits; } #endif return true; @@ -49,9 +93,9 @@ bool set_preferred_target_page_bits(int bits) void finalize_target_page_bits(void) { #ifdef TARGET_PAGE_BITS_VARY - if (target_page_bits == 0) { - target_page_bits = TARGET_PAGE_BITS_MIN; + if (init_target_page.bits == 0) { + init_target_page.bits = TARGET_PAGE_BITS_MIN; } - target_page_bits_decided = true; + init_target_page.decided = true; #endif } From patchwork Wed Oct 23 15:45:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1182280 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="FuHRWKfk"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46yw7R585Lz9sPf for ; Thu, 24 Oct 2019 03:00:03 +1100 (AEDT) Received: from localhost ([::1]:40356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNJ3I-000191-UO for incoming@patchwork.ozlabs.org; Wed, 23 Oct 2019 12:00:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42557) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNIp4-0004ky-9O for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNIp2-0005Z9-Uw for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:17 -0400 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]:44118) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNIp1-0005TG-1P for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:15 -0400 Received: by mail-qt1-x843.google.com with SMTP id z22so12436658qtq.11 for ; Wed, 23 Oct 2019 08:45:14 -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 :mime-version:content-transfer-encoding; bh=qse2dU+9DDWN9Jnukz33b9KCxbTfJVcInGskyFTMfNk=; b=FuHRWKfkKKiXQSuHFviEiHAH6gXryMMRKVBOqBve87UIFlFlT0XuwqdeAcoSykCNo+ /SQRVg6LCxROdcCyyB8MqO0/tBKTs+31Qo87VVKM2w7Rs5Z++Ib8TG4ePTP6s1LAH6Gv 0H1Ju0rjEAnzHpM5K0lmisiLOjSUr1fEREJ81WOSLWBQKFJ5v2q5IRdrqaXmpGC54poX EtwvZUZsqu5Ij+HoZwMoUQbMRupaTSwHppN3TqfoRyTXIMiCWYOyaxjZ08baiNa7qFcL 1j31W2UzjjidYB9OU/l1HSfegl/zPVAH7clIMLy8jkWygGjkI2FqudlMbL+kW4e0SY1/ Gtrw== 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:mime-version:content-transfer-encoding; bh=qse2dU+9DDWN9Jnukz33b9KCxbTfJVcInGskyFTMfNk=; b=hkfN21KPaaXKnpmo7HaC9iDHkn+C+ucMw/ZVaY9SmZMNlIeQvv0/OPcGN86rGXelBT OBQWmdYrambdLGJQU/eGRITcxyFzmc4DxVj7I9MeC89Tx+xYgVgmEXHlpF8hAqDIGoxu XUryiaf7K9MSaRvTHuOvuxFQyRPTGYd95Fv5OyKKL8m9V/uymRxFmKo+lho0w2hVYea4 6EALdpMfoEjRUWb+ejPFZutmRd/jO9oUoyfqpMjYeMhh7AZRTGkjOC9vpfsoWnk4cAI2 6HNc/T/Th3AZE4z6lEYnt+2hUQPmCxw39Z0OUsQ93xGHl3Gom0q65ztp6kILRFtELwcm RdCA== X-Gm-Message-State: APjAAAWx8cDrGhBd6qL9ojXI0j8jFbiM1gjoI9tcS2TQA7cPoH503GRy Nx/+aXIW9W3h+icAR5KMeCO/nmt8YIw= X-Google-Smtp-Source: APXvYqw/ZwCxViqMKoKEV2tcDv81yvz1OKL9h6uhBdnTrs/97/frVC5+Wff5yZs6Pils3qpq85WFnQ== X-Received: by 2002:ac8:7082:: with SMTP id y2mr10067641qto.386.1571845513447; Wed, 23 Oct 2019 08:45:13 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-50.nyc.biz.rr.com. [172.254.253.50]) by smtp.gmail.com with ESMTPSA id o1sm2456272qtb.82.2019.10.23.08.45.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 08:45:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 5/7] exec: Restrict TARGET_PAGE_BITS_VARY assert to CONFIG_DEBUG_TCG Date: Wed, 23 Oct 2019 11:45:03 -0400 Message-Id: <20191023154505.30521-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023154505.30521-1-richard.henderson@linaro.org> References: <20191023154505.30521-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::843 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This reduces the size of a release build by about 10k. Noticably, within the tlb miss helpers. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- include/exec/cpu-all.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 76515dc8d9..d3e4660d50 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -219,7 +219,11 @@ extern const TargetPageBits target_page; #else extern TargetPageBits target_page; # endif -#define TARGET_PAGE_BITS (assert(target_page.decided), target_page.bits) +# ifdef CONFIG_DEBUG_TCG +# define TARGET_PAGE_BITS (assert(target_page.decided), target_page.bits) +# else +# define TARGET_PAGE_BITS target_page.bits +# endif #else #define TARGET_PAGE_BITS_MIN TARGET_PAGE_BITS #endif From patchwork Wed Oct 23 15:45:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1182315 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="spWfgZhK"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46yxSH3kyQz9sNx for ; Thu, 24 Oct 2019 03:59:42 +1100 (AEDT) Received: from localhost ([::1]:41860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNJz0-0005k4-Oi for incoming@patchwork.ozlabs.org; Wed, 23 Oct 2019 12:59:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42562) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNIp4-0004lR-5S for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNIp3-0005Zj-31 for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:18 -0400 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]:41354) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNIp2-0005Wg-Uy for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:17 -0400 Received: by mail-qk1-x730.google.com with SMTP id p10so20175533qkg.8 for ; Wed, 23 Oct 2019 08:45:15 -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=c7P4icDHFNd0mEdVm74bSlE92DJndGlIMYmWQpTcLCI=; b=spWfgZhKpuPn2IsUtYCPi7864OHr4cq5CqGow2D5RkOD7mZHHJQ7K+SGj9an4k9GSu mrUIOnZOw/HHyXmTaEmPpWuqr12wWdjQd9qrFyOic85uFl52oJzAFbXViVRAP/e4sLW2 TSDvGQmnCl/NVCDzSGpXm04rVN2IYgS+HVfLMWxJrVGfLgTRIR/YoG3omnP+K80pCPx8 3Z7e3K9TJoepvdSz2PbnGy2HmPBvub/tCOz10vYKwc2Oa1hbjyH9/BuTU4lwI8U14rvZ NElFgUXr9m7L5segePxBAhlbvuC4IoyvF2Nv3itMjjuL0LK45ZMq4apnKVYPz3h5fCky ME8w== 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=c7P4icDHFNd0mEdVm74bSlE92DJndGlIMYmWQpTcLCI=; b=e+Gfm8iMxQ4rMcBf65E3VD/tFbDExds/Cd2eiYxAMb+5e45IO7yC4oEz8DSTjikyTa I86MblWtX1nkpNeoWvDvYX+FaG9/vj84em0wu2UfwZS7udUGKdKisg+I0ay2Wg5dF7Zo FmY63h4pMmp2Mzojm/hz047TMzbp3r6kX+vAwFdkqc3mNRKBz5qUSZM+9Kswa/wpGx35 iEEfu6bliGjsOlS6fL2aPgx3ZccmZDax/5w0RcHaOwIS60eRnJyBHWxOsY6iUboo0KC7 doBTlpBfAzj4EeiafD6Jw+D97AA1wq3cjDT026OXQ+YFf3DhAfaFkEmFBy8QTXnOuO5M 94Rg== X-Gm-Message-State: APjAAAUMLDR73zAxLv+wGnOdYX2zBnYYATummb0Pz0YhaXcnTroGw0yg 3lLs/9sJz+qDBXp8Z/RyjQF1L7ZxFfU= X-Google-Smtp-Source: APXvYqyk86RJyqvah5hKMrKLYCaOfMHi5vjNKRedYdTHSp0OA7YPO3t5ZqzbpQ9mkpCzykutZnE2eA== X-Received: by 2002:a37:85c1:: with SMTP id h184mr8893826qkd.195.1571845515036; Wed, 23 Oct 2019 08:45:15 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-50.nyc.biz.rr.com. [172.254.253.50]) by smtp.gmail.com with ESMTPSA id o1sm2456272qtb.82.2019.10.23.08.45.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 08:45:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 6/7] exec: Promote TARGET_PAGE_MASK to target_long Date: Wed, 23 Oct 2019 11:45:04 -0400 Message-Id: <20191023154505.30521-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023154505.30521-1-richard.henderson@linaro.org> References: <20191023154505.30521-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::730 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" There are some uint64_t uses that expect TARGET_PAGE_MASK to extend for a 32-bit, so this must continue to be a signed type. Define based on TARGET_PAGE_BITS not TARGET_PAGE_SIZE; this will make a following patch more clear. This should not have a functional effect so far. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index d3e4660d50..ba6d3306bf 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -229,7 +229,7 @@ extern TargetPageBits target_page; #endif #define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) -#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1) +#define TARGET_PAGE_MASK ((target_long)-1 << TARGET_PAGE_BITS) #define TARGET_PAGE_ALIGN(addr) ROUND_UP((addr), TARGET_PAGE_SIZE) /* Using intptr_t ensures that qemu_*_page_mask is sign-extended even From patchwork Wed Oct 23 15:45:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1182281 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="xvAGOaSr"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46ywFs283yz9sNx for ; Thu, 24 Oct 2019 03:05:37 +1100 (AEDT) Received: from localhost ([::1]:40468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNJ8g-0005KM-9a for incoming@patchwork.ozlabs.org; Wed, 23 Oct 2019 12:05:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42576) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNIp4-0004mY-RS for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNIp3-0005aY-FS for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:18 -0400 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]:42626) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNIp3-0005Zd-Au for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:17 -0400 Received: by mail-qk1-x741.google.com with SMTP id m4so3244209qke.9 for ; Wed, 23 Oct 2019 08:45:17 -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=JjWcaTsnfa9rn5Sr9u0qn7xbDpDf/Xngde06dSTH5/8=; b=xvAGOaSrw0eVg5PLraV/c3pa1IsjmiLrQ/GZQUHU+4DVYyTs58Qbmsa1U1sihy0SAM HhhkF41bkgIkLMwVGC59UrY/Vrvnx2BzoI41MRbR/68WItfrITAdhNc3UG+1cnENG6Y0 XMjcb9Wo2zYhdrHKYzC/8bvDSqpwKS96tEKnGo2DUzN0fI0/kfyvMxu91p97az6Gkbgk LWmAMQsOBR+8pEu3XqtXlNmAaw6h35WxTFW8CPe/K4Txmb0aaDNbiklT9ZqV1DkFWZoo zJQZzOvkfFsocg8SWY9T3zmy9+m8TVDYF5G6SwG3IK1pxd4fwp0lrtm+5Z7fOSRFbhkH yW6A== 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=JjWcaTsnfa9rn5Sr9u0qn7xbDpDf/Xngde06dSTH5/8=; b=Tx+hS39Zh7YzTLeeihcxoinddu8sZeU5EM+ivinIlYBVxKpQYlifuDxxrheAIEoY8Z o65svB2J2zN69Hx/6cmkeYstIjDyTvxvmIlsBji8yqua7j0SmqfpWzUDlZeH7SIvs2D3 iROwWBL047lAZ5JfzBN5RqE2pSmDD9jYnAxhAzN1asSSiGObB/RLlw52FMwTELkfIZnW zqC0LZBP7TBHLY8wt6NX+MG48VoqWbsqVz9l2l0FDlpg2FLw1lgC7te+PI+hQAHGIrX3 BL1kwSVqrkLlQRnZA4Vd3biKLw7IYvL8+w01XSmlP6Qv6FE9SRBufIysPonGQ7dh8bSH XBMQ== X-Gm-Message-State: APjAAAUIQMRUhleTexGBbDgy83vfV+q7oQ+9LGK4vHipALVUKeGS/Wyn pYGkewmwC5SncKweh/Cm/UboRnWxclM= X-Google-Smtp-Source: APXvYqzsG5OEUNH6cqyMrYkUZCFKFOlkOfKxnrAKf2eA7rgvL2bs56EOGsDwFiRK8Gd/2WyzO4MdpA== X-Received: by 2002:a37:90c2:: with SMTP id s185mr1977393qkd.377.1571845516352; Wed, 23 Oct 2019 08:45:16 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-50.nyc.biz.rr.com. [172.254.253.50]) by smtp.gmail.com with ESMTPSA id o1sm2456272qtb.82.2019.10.23.08.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 08:45:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 7/7] exec: Cache TARGET_PAGE_MASK for TARGET_PAGE_BITS_VARY Date: Wed, 23 Oct 2019 11:45:05 -0400 Message-Id: <20191023154505.30521-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023154505.30521-1-richard.henderson@linaro.org> References: <20191023154505.30521-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::741 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This eliminates a set of runtime shifts. It turns out that we require TARGET_PAGE_MASK more often than TARGET_PAGE_SIZE, so redefine TARGET_PAGE_SIZE based on TARGET_PAGE_MASK instead of the other way around. Reviewed-by: David Hildenbrand Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 8 ++++++-- exec-vary.c | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index ba6d3306bf..08b3a5ab06 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -213,6 +213,7 @@ static inline void stl_phys_notdirty(AddressSpace *as, hwaddr addr, uint32_t val typedef struct { bool decided; int bits; + target_long mask; } TargetPageBits; # if defined(CONFIG_ATTRIBUTE_ALIAS) || !defined(IN_EXEC_VARY) extern const TargetPageBits target_page; @@ -221,15 +222,18 @@ extern TargetPageBits target_page; # endif # ifdef CONFIG_DEBUG_TCG # define TARGET_PAGE_BITS (assert(target_page.decided), target_page.bits) +# define TARGET_PAGE_MASK (assert(target_page.decided), target_page.mask) # else # define TARGET_PAGE_BITS target_page.bits +# define TARGET_PAGE_MASK target_page.mask # endif +# define TARGET_PAGE_SIZE (-(int)TARGET_PAGE_MASK) #else #define TARGET_PAGE_BITS_MIN TARGET_PAGE_BITS +#define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) +#define TARGET_PAGE_MASK ((target_long)-1 << TARGET_PAGE_BITS) #endif -#define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) -#define TARGET_PAGE_MASK ((target_long)-1 << TARGET_PAGE_BITS) #define TARGET_PAGE_ALIGN(addr) ROUND_UP((addr), TARGET_PAGE_SIZE) /* Using intptr_t ensures that qemu_*_page_mask is sign-extended even diff --git a/exec-vary.c b/exec-vary.c index e0befd502a..0594f61fef 100644 --- a/exec-vary.c +++ b/exec-vary.c @@ -97,5 +97,6 @@ void finalize_target_page_bits(void) init_target_page.bits = TARGET_PAGE_BITS_MIN; } init_target_page.decided = true; + init_target_page.mask = (target_long)-1 << init_target_page.bits; #endif }