From nobody Mon Apr 29 10:17:55 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507214294678357.6698879327265; Thu, 5 Oct 2017 07:38:14 -0700 (PDT) Received: from localhost ([::1]:40185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e07Hi-0003WS-Iu for importer@patchew.org; Thu, 05 Oct 2017 10:37:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e07G0-0002Gv-MC for qemu-devel@nongnu.org; Thu, 05 Oct 2017 10:36:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e07Fv-0001sx-W4 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 10:36:12 -0400 Received: from mail-qt0-x232.google.com ([2607:f8b0:400d:c0d::232]:56424) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e07Fv-0001sK-RY for qemu-devel@nongnu.org; Thu, 05 Oct 2017 10:36:07 -0400 Received: by mail-qt0-x232.google.com with SMTP id 34so8618267qtb.13 for ; Thu, 05 Oct 2017 07:36:07 -0700 (PDT) Received: from bigtime.twiddle.net.com ([2606:a000:7a4a:b100::1b]) by smtp.gmail.com with ESMTPSA id c13sm8277148ywm.101.2017.10.05.07.36.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Oct 2017 07:36:06 -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=95+f3I17oa+hAr3IQ9BfOqpphaiQAkB08avVzG839m8=; b=gtcVb/7me/Pd6xxk5y3KhL3w2XcHG5cYT3t1dvOY3jhUvLJUMI+YS0MZ6G0R13QnJd e0S6D3jZVXFk7lpgqSyI0tKWBUT4oxZYEGMKHrFlp/Oxew3z0McPzkGGKTNcd3Vbi7Kg 17YaqWBoD7KOuDmg1hN7NKh8lRLsZsiaoUrv4= 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=95+f3I17oa+hAr3IQ9BfOqpphaiQAkB08avVzG839m8=; b=AW9CuTlc1OPIm/Rusr+G+6vhMgKOAvBNp/9kWpgHAB5gq33OuejxxwtWm07094Sg3b atFNFdSNBS+u5mr4RmqVlqcqhG9rVw8Y4HSFmjKfb7XD4AHVM1bTkAWWtdgrbDarkbel xFul7TCuBq5ok7+SKozTUPS2OOZIhlB61Td8wUrvi+qWMw4ysapWPs+Q/Vyv4eRJqzKO i3HHQmMKVx+a/9fDe3+tfWBXwf4dsIWgsAqxi9E6dSvKpXeGhd+Q304umRubgz4pm4+I ei8n3QZFgzIqMmFi1QxcmO4BX0Y/jJPX0A2/J7dohAKJtm6RhgPmwVxe7P1vzEddzkbS nygQ== X-Gm-Message-State: AMCzsaVrBuJ/1eIe/mA2Yi7z7SlpkiDiOjVpgCtmUcqn1B0x9O+kVL9I XHoygaYT0AhDwEjvcOA0CuRFiISfUSI= X-Google-Smtp-Source: AOwi7QAuBbDrkFJlcNnQAjnkgu35ZUj63H9hRgZ0Qf7YGvxbNzWUMoUubYcR2G646eD463Ddlq9hFw== X-Received: by 10.129.175.83 with SMTP id x19mr5238617ywj.289.1507214167032; Thu, 05 Oct 2017 07:36:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 10:35:58 -0400 Message-Id: <20171005143601.21584-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171005143601.21584-1-richard.henderson@linaro.org> References: <20171005143601.21584-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::232 Subject: [Qemu-devel] [PATCH v2 1/4] linux-user: Allow -R values up to 0xffff0000 for 32-bit ARM guests 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, riku.voipio@iki.fi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Maydell The 32-bit ARM validate_guest_space() check tests whether the specified -R value leaves enough space for us to put the commpage in at 0xffff0f00. However it was incorrectly doing a <=3D check for the check against (guest_base + guest_size), which meant that it wasn't permitting the guest space to butt right up against the commpage. Fix the comparison, so that -R values all the way up to 0xffff0000 work correctly. Reviewed-by: Emilio G. Cota Signed-off-by: Peter Maydell Message-Id: <1507047703-10774-1-git-send-email-peter.maydell@linaro.org> Signed-off-by: Richard Henderson --- linux-user/elfload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 79062882ba..3b857fbc9c 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -377,7 +377,7 @@ static int validate_guest_space(unsigned long guest_bas= e, * then there is no way we can allocate it. */ if (test_page_addr >=3D guest_base - && test_page_addr <=3D (guest_base + guest_size)) { + && test_page_addr < (guest_base + guest_size)) { return -1; } =20 --=20 2.13.6 From nobody Mon Apr 29 10:17:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507214583448699.98199291831; Thu, 5 Oct 2017 07:43:03 -0700 (PDT) Received: from localhost ([::1]:40218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e07Mc-0007Y4-Op for importer@patchew.org; Thu, 05 Oct 2017 10:43:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e07Fy-0002Fx-L8 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 10:36:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e07Fx-0001v6-Nj for qemu-devel@nongnu.org; Thu, 05 Oct 2017 10:36:10 -0400 Received: from mail-qt0-x22c.google.com ([2607:f8b0:400d:c0d::22c]:49147) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e07Fx-0001uQ-J5 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 10:36:09 -0400 Received: by mail-qt0-x22c.google.com with SMTP id d13so25048010qta.5 for ; Thu, 05 Oct 2017 07:36:09 -0700 (PDT) Received: from bigtime.twiddle.net.com ([2606:a000:7a4a:b100::1b]) by smtp.gmail.com with ESMTPSA id c13sm8277148ywm.101.2017.10.05.07.36.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Oct 2017 07:36:07 -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=IlVJtg7jsV6bcBya3yYGZw68nCz70QiaFT1rPAbZNd4=; b=ZnIDtrm1myVKLWbRmdbYNqnvJCku+75vtiKCZp8xT0OC878JRmc5lhBdQ46Il4yJ1+ bmTP+nsonYDrB5cM7OZ64aAo37/zDRnRLBapjWBKvIOStbdPrEg3aVRco++hNLlB2Fdo h4pmgSiqV2Tly6sLF0SEYDEszaRUShNNVjVrc= 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=IlVJtg7jsV6bcBya3yYGZw68nCz70QiaFT1rPAbZNd4=; b=Fn2VzsGw0Qb1c+eJfY58rt3FiUkT0nfTifCuOXzN0Ask95YPKcgrq0B/PMYLGj7N5h A7AposUDXmaQwn0FUeT70Awg4eDeHM+1biFi4YYSm6vyvAof1wDqiwr7VzdgTJsX9e8D UbHJivKo6Hs8fSzpvQI2bGUNzikKIPTTPf5uLrtECaHEjjRIAnezvZwyvXseFXdEvz/g 3aUKukFKps7bQojDmfUzGYKV70DGQWoFi+TWwUFujeRwJ4p+BF77mQA+WvEnZPu3+A2A wxUEpNqSwePVMcI/3nSiTtIVy84Cp8vbXnnQdW5wUjCEYQ+QfwcKWc3dmkZavLbroeSf +OQg== X-Gm-Message-State: AHPjjUjp6LUFxeuJUjMFAFQ9jhSCfm5Hx2rG6cNP8Er5mpQ5kMcL39a0 Wos07VUd3vNjZL736AYPL9dDu5wYpTs= X-Google-Smtp-Source: AOwi7QDTae0+LD7WbN5d6jOx2PAcZp+TVh/3l2sF0eKgug881cvhKT9KJ/3zA2BE1fW1K/XSL1Fgvw== X-Received: by 10.129.121.4 with SMTP id u4mr19889241ywc.71.1507214168693; Thu, 05 Oct 2017 07:36:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 10:35:59 -0400 Message-Id: <20171005143601.21584-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171005143601.21584-1-richard.henderson@linaro.org> References: <20171005143601.21584-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::22c Subject: [Qemu-devel] [PATCH v2 2/4] tcg: Fix off-by-one in assert in page_set_flags 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, riku.voipio@iki.fi, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Richard Henderson Most of the users of page_set_flags offset (page, page + len) as the end points. One might consider this an error, since the other users do supply an endpoint as the last byte of the region. However, the first thing that page_set_flags does is round end UP to the start of the next page. Which means computing page + len - 1 is in the end pointless. Therefore, accept this usage and do not assert when given the exact size of the vm as the endpoint. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20170708025030.15845-2-rth@twiddle.net> --- accel/tcg/translate-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 2d1ed06065..ebfc2e7024 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2090,7 +2090,7 @@ void page_set_flags(target_ulong start, target_ulong = end, int flags) guest address space. If this assert fires, it probably indicates a missing call to h2g_valid. */ #if TARGET_ABI_BITS > L1_MAP_ADDR_SPACE_BITS - assert(end < ((target_ulong)1 << L1_MAP_ADDR_SPACE_BITS)); + assert(end <=3D ((target_ulong)1 << L1_MAP_ADDR_SPACE_BITS)); #endif assert(start < end); assert_memory_lock(); --=20 2.13.6 From nobody Mon Apr 29 10:17:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150721429348812.340368801556565; Thu, 5 Oct 2017 07:38:13 -0700 (PDT) Received: from localhost ([::1]:40186 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e07Hj-0003XE-56 for importer@patchew.org; Thu, 05 Oct 2017 10:37:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e07G1-0002HT-0U for qemu-devel@nongnu.org; Thu, 05 Oct 2017 10:36:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e07Fz-0001x9-9j for qemu-devel@nongnu.org; Thu, 05 Oct 2017 10:36:12 -0400 Received: from mail-qt0-x236.google.com ([2607:f8b0:400d:c0d::236]:51190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e07Fz-0001wj-4X for qemu-devel@nongnu.org; Thu, 05 Oct 2017 10:36:11 -0400 Received: by mail-qt0-x236.google.com with SMTP id f15so25743650qtf.7 for ; Thu, 05 Oct 2017 07:36:11 -0700 (PDT) Received: from bigtime.twiddle.net.com ([2606:a000:7a4a:b100::1b]) by smtp.gmail.com with ESMTPSA id c13sm8277148ywm.101.2017.10.05.07.36.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Oct 2017 07:36: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=8MPya8y2mIfaj5u/2uwzfaPNBjR97VQyGpq6Qna7SJw=; b=FyFr1A/5DZEUtDX+ZlKkgtBVE0vzZcK5S1FLCeJA/MFHRSknHUtq3U868zbHoOCmXU 38fp+KE0dOO4sFdWdN6IzLgGTHAdz8tA7rqzKA06+BfQlESWQtuEYLuyH+MP0OCHWwlO ww8ygwrcp/feYw7lhB5/me9rtu+Kdnbj9OGyg= 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=8MPya8y2mIfaj5u/2uwzfaPNBjR97VQyGpq6Qna7SJw=; b=L82ygOaSALKhv05rW7NzQjkAi1zV+Wo35aN18r8ehgP5HehmiUKrqJ4f8euuZC5oOH RzyAV8+CNTP190v2PyKuXye/UaO2vUvX+frTwO7PqwL2140sXVJ8Q8rPDvN6SU/GsrmL 1GASeagbkM8+U4/aRhH1KTT0HoaDpSMQWeit/qptKLHCKsd36uwUFutyB65vWTYkT3Yc 9dRgSuSa2WhVbdO8EDi0x7t5dJbQdt600nUYKHjZ+YVON1X0sBJWUSEOqbZpbTxb+7aE vbPjydMMA2l7AXdAPKoTIoyqtkleh409UlED5Ng0PG8DrQhjeds5J7R0oGRHr1O9e0h9 fY1w== X-Gm-Message-State: AMCzsaUQ76A/FE4JHN8Q4/TUuc3RulqDD2hO1YqqMgJMvn2t4+e0GFuu wxWcv1aU+W3jXRr/WFy6CZqyz2DK98c= X-Google-Smtp-Source: AOwi7QB0Epdy9RJGyJsrVzOQvvpy7goxOCRX09WvRB9HusaGkIi6Oz581fo8UXJuTFFmnwNrrTRIAQ== X-Received: by 10.129.172.22 with SMTP id k22mr5356324ywh.52.1507214170224; Thu, 05 Oct 2017 07:36:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 10:36:00 -0400 Message-Id: <20171005143601.21584-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171005143601.21584-1-richard.henderson@linaro.org> References: <20171005143601.21584-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::236 Subject: [Qemu-devel] [PATCH v2 3/4] linux-user: Tidy and enforce reserved_va initialization 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, riku.voipio@iki.fi, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson We had a check using TARGET_VIRT_ADDR_SPACE_BITS to make sure that the allocation coming in from the command-line option was not too large, but that didn't include target-specific knowledge about other restrictions on user-space. Remove several target-specific hacks in linux-user/main.c. For MIPS and Nios, we can replace them with proper adjustments to the respective target's TARGET_VIRT_ADDR_SPACE_BITS definition. For ARM, we had no existing ifdef but I suspect that the current default value of 0xf7000000 was chosen with this in mind. Define a workable value in linux-user/arm/, and also document why the special case is required. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-Id: <20170708025030.15845-3-rth@twiddle.net> --- linux-user/arm/target_cpu.h | 4 ++++ target/mips/mips-defs.h | 6 +++++- target/nios2/cpu.h | 6 +++++- linux-user/main.c | 38 +++++++++++++++++++++++++------------- 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/linux-user/arm/target_cpu.h b/linux-user/arm/target_cpu.h index d888219150..c3eb4b243d 100644 --- a/linux-user/arm/target_cpu.h +++ b/linux-user/arm/target_cpu.h @@ -19,6 +19,10 @@ #ifndef ARM_TARGET_CPU_H #define ARM_TARGET_CPU_H =20 +/* We need to be able to map the commpage. + See validate_guest_space in linux-user/elfload.c. */ +#define MAX_RESERVED_VA 0xffff0000ul + static inline void cpu_clone_regs(CPUARMState *env, target_ulong newsp) { if (newsp) { diff --git a/target/mips/mips-defs.h b/target/mips/mips-defs.h index 047554ee45..d239069975 100644 --- a/target/mips/mips-defs.h +++ b/target/mips/mips-defs.h @@ -15,7 +15,11 @@ #else #define TARGET_LONG_BITS 32 #define TARGET_PHYS_ADDR_SPACE_BITS 40 -#define TARGET_VIRT_ADDR_SPACE_BITS 32 +# ifdef CONFIG_USER_ONLY +# define TARGET_VIRT_ADDR_SPACE_BITS 31 +# else +# define TARGET_VIRT_ADDR_SPACE_BITS 32 +#endif #endif =20 /* Masks used to mark instructions to indicate which ISA level they diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 50d803a217..9119eee587 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -226,7 +226,11 @@ qemu_irq *nios2_cpu_pic_init(Nios2CPU *cpu); void nios2_check_interrupts(CPUNios2State *env); =20 #define TARGET_PHYS_ADDR_SPACE_BITS 32 -#define TARGET_VIRT_ADDR_SPACE_BITS 32 +#ifdef CONFIG_USER_ONLY +# define TARGET_VIRT_ADDR_SPACE_BITS 31 +#else +# define TARGET_VIRT_ADDR_SPACE_BITS 32 +#endif =20 #define cpu_init(cpu_model) cpu_generic_init(TYPE_NIOS2_CPU, cpu_model) =20 diff --git a/linux-user/main.c b/linux-user/main.c index 829f974662..fd54d344bb 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -60,23 +60,38 @@ do { = \ } \ } while (0) =20 -#if (TARGET_LONG_BITS =3D=3D 32) && (HOST_LONG_BITS =3D=3D 64) /* * When running 32-on-64 we should make sure we can fit all of the possible * guest address space into a contiguous chunk of virtual host memory. * * This way we will never overlap with our own libraries or binaries or st= ack * or anything else that QEMU maps. + * + * Many cpus reserve the high bit (or more than one for some 64-bit cpus) + * of the address for the kernel. Some cpus rely on this and user space + * uses the high bit(s) for pointer tagging and the like. For them, we + * must preserve the expected address space. */ -# if defined(TARGET_MIPS) || defined(TARGET_NIOS2) -/* - * MIPS only supports 31 bits of virtual address space for user space. - * Nios2 also only supports 31 bits. - */ -unsigned long reserved_va =3D 0x77000000; +#ifndef MAX_RESERVED_VA +# if HOST_LONG_BITS > TARGET_VIRT_ADDR_SPACE_BITS +# if TARGET_VIRT_ADDR_SPACE_BITS =3D=3D 32 && \ + (TARGET_LONG_BITS =3D=3D 32 || defined(TARGET_ABI32)) +/* There are a number of places where we assign reserved_va to a variable + of type abi_ulong and expect it to fit. Avoid the last page. */ +# define MAX_RESERVED_VA (0xfffffffful & TARGET_PAGE_MASK) +# else +# define MAX_RESERVED_VA (1ul << TARGET_VIRT_ADDR_SPACE_BITS) +# endif # else -unsigned long reserved_va =3D 0xf7000000; +# define MAX_RESERVED_VA 0 # endif +#endif + +/* That said, reserving *too* much vm space via mmap can run into problems + with rlimits, oom due to page table creation, etc. We will still try i= t, + if directed by the command-line option, but not by default. */ +#if HOST_LONG_BITS =3D=3D 64 && TARGET_VIRT_ADDR_SPACE_BITS <=3D 32 +unsigned long reserved_va =3D MAX_RESERVED_VA; #else unsigned long reserved_va; #endif @@ -3978,11 +3993,8 @@ static void handle_arg_reserved_va(const char *arg) unsigned long unshifted =3D reserved_va; p++; reserved_va <<=3D shift; - if (((reserved_va >> shift) !=3D unshifted) -#if HOST_LONG_BITS > TARGET_VIRT_ADDR_SPACE_BITS - || (reserved_va > (1ul << TARGET_VIRT_ADDR_SPACE_BITS)) -#endif - ) { + if (reserved_va >> shift !=3D unshifted + || (MAX_RESERVED_VA && reserved_va > MAX_RESERVED_VA)) { fprintf(stderr, "Reserved virtual address too big\n"); exit(EXIT_FAILURE); } --=20 2.13.6 From nobody Mon Apr 29 10:17:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507214293554248.4935624312393; Thu, 5 Oct 2017 07:38:13 -0700 (PDT) Received: from localhost ([::1]:40187 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e07Ho-0003bg-Lg for importer@patchew.org; Thu, 05 Oct 2017 10:38:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e07G4-0002KA-JG for qemu-devel@nongnu.org; Thu, 05 Oct 2017 10:36:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e07G0-0001yp-Js for qemu-devel@nongnu.org; Thu, 05 Oct 2017 10:36:16 -0400 Received: from mail-qt0-x22f.google.com ([2607:f8b0:400d:c0d::22f]:55452) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e07G0-0001yQ-F1 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 10:36:12 -0400 Received: by mail-qt0-x22f.google.com with SMTP id x54so25684375qth.12 for ; Thu, 05 Oct 2017 07:36:12 -0700 (PDT) Received: from bigtime.twiddle.net.com ([2606:a000:7a4a:b100::1b]) by smtp.gmail.com with ESMTPSA id c13sm8277148ywm.101.2017.10.05.07.36.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Oct 2017 07:36:10 -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=cXxdyWFqydMB2qOTu/4wULu4y8k6Bslrjk6HWtmobII=; b=PpACFAvARajS1egSQP5tkIP5skQTLqBPlOLiFsdyr/dfTgAmEVR1EbcMLLbdGHWG8U QNrvYmJ969lX/z8/B6ZWAFwAxN8hOoQVeKPCKWXCl/VZ1U2Ysr4XuPAt4ZmxFUaCa+qC 64FG3yF/Xh255j9zMvUuUEwRlZWUR4tZlb8So= 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=cXxdyWFqydMB2qOTu/4wULu4y8k6Bslrjk6HWtmobII=; b=ivtK+hWI30pxqoCtPq/0YZM9EooGHlvsj0gRJSuqosWbR3KL6R+eC3elLm4Em2bhvW T8IjEIQagh8hkeUL29GhOAOhUdAkbfJOrHOSa55PoB5Y9+TPoZ5edxtvaPf50nkc4ujM wEy+SSN67q6Xpio7wVDpdI5JFf0ugOpbNS34ke4Hob54Oeeie67jefVjtsmRojpESE6D LcbtCbnLsuXeJADf0Q5uC+t5675MRIkNS+CB2zHP1+cG+Oz42hdJ1yxerLN4uv6wkF6O n7LKENXTmqplB6JusKVxkKLn2BP4OGeyMGXa5bZxpbAi62uz6qlByuqQG7YjQR6e+b32 3Bbw== X-Gm-Message-State: AMCzsaVX1ytnEExxZhtNtSuU2B/YXeJN9deDiWbizYC3CxsleJYMklQn 3NnTxhSx60ULyYH09Dwe0rfR744b13E= X-Google-Smtp-Source: AOwi7QC7xmPtbNiViNg3i3r22a69Dm7jSU0L3KWncsPfoqFczTPnvZq6Ig9+2vl/Rhvqt1tCp9hLsQ== X-Received: by 10.129.120.79 with SMTP id t76mr9347734ywc.126.1507214171647; Thu, 05 Oct 2017 07:36:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 10:36:01 -0400 Message-Id: <20171005143601.21584-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171005143601.21584-1-richard.henderson@linaro.org> References: <20171005143601.21584-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::22f Subject: [Qemu-devel] [PATCH v2 4/4] linux-user/sh4: Reduce TARGET_VIRT_ADDR_SPACE_BITS to 31 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, riku.voipio@iki.fi, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Richard Henderson The real kernel has TASK_SIZE as 0x7c000000, due to quirks with a couple of SH parts. But nominally user-space is limited to 2GB. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20170708025030.15845-4-rth@twiddle.net> --- target/sh4/cpu.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h index 79f85d3365..123f34783a 100644 --- a/target/sh4/cpu.h +++ b/target/sh4/cpu.h @@ -45,7 +45,11 @@ #define TARGET_PAGE_BITS 12 /* 4k XXXXX */ =20 #define TARGET_PHYS_ADDR_SPACE_BITS 32 -#define TARGET_VIRT_ADDR_SPACE_BITS 32 +#ifdef CONFIG_USER_ONLY +# define TARGET_VIRT_ADDR_SPACE_BITS 31 +#else +# define TARGET_VIRT_ADDR_SPACE_BITS 32 +#endif =20 #define SR_MD 30 #define SR_RB 29 --=20 2.13.6