From patchwork Wed Feb 28 21:06:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10249747 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5ECAF60212 for ; Wed, 28 Feb 2018 21:08:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DBF5287A8 for ; Wed, 28 Feb 2018 21:08:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 428E428A67; Wed, 28 Feb 2018 21:08:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, HK_RANDOM_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5F707287A8 for ; Wed, 28 Feb 2018 21:08:23 +0000 (UTC) Received: from localhost ([::1]:46921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er8xa-0007Hs-HA for patchwork-qemu-devel@patchwork.kernel.org; Wed, 28 Feb 2018 16:08:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er8vx-0005jK-0m for qemu-devel@nongnu.org; Wed, 28 Feb 2018 16:06:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1er8vv-0000d1-Sr for qemu-devel@nongnu.org; Wed, 28 Feb 2018 16:06:40 -0500 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]:44890) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1er8vv-0000bc-MA; Wed, 28 Feb 2018 16:06:39 -0500 Received: by mail-lf0-x244.google.com with SMTP id v9so5599716lfa.11; Wed, 28 Feb 2018 13:06:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f0UAVJcUDq2ABjMeysWuqgBuFlb2SfgmwZQ7VJ5CUAM=; b=Ordb5htqB3M6RtzDBBhuOwyurS0lO3GnGVB+oT61fxiS/Mr4RVgYq+g09KPIzioD1z piGanziY35afyJRKNb5rqoXjQXiBGgM2SIHfEEuCvknaL0jpXzNngvgNNN+1LkJ8sXBe r4aENLdVRN1zsnUjENvosp/1c3vxCNTe1slJ3VT7gSgZZpGZF4Xk6cnrzykfiDn7tjc3 jEIun2W0x9esbcbnrEEt8OH4Pat75lB8kcK90bGLJI82Y7FemM/oa1q56XRu2wW2cG+h 1dNt0tEjZ2X208RB7uH2swZmG60MGtDWsrhRJnveiagHjsXpFhIod1IUBr3FBt3q+ALB l/wQ== 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=f0UAVJcUDq2ABjMeysWuqgBuFlb2SfgmwZQ7VJ5CUAM=; b=FfzCjQAhwp0mEJCQKlwRbp1z7j3PudEizdFwJChJvpDS5HauweYMlUx6Qy+9ZrNnbX I6AkzPEhvM0bJFE6hZlqWZ9/LCAkikIbmllDziyzW4sVDTfqOVOyqv/Q+ICGLlF8VFDA BvWVowJ9zP8OEPlCVac3rJ3eip2kVPCMwIheH0GG5fVi5U0nKB9AQ+leoZt3r8IMRLKf 5MOvZaEU+oWzoXt6r7wA0o5HFIOUjk37bGQOAhXtwp54qh7jnXitn3SzMUiNzmmBvk8q H9KTsKOaPqVglFIOGGxdAXZaHsgfJKNuK+rfpu4IsYBwPW1srCtjPtlV5uERTgUoJd0h XM4Q== X-Gm-Message-State: APf1xPA2OfWsPP19arlW+hZtXm2xyo1KzHU9WhtXijItJ1RE79hUby97 buTLCr2WBQryxMerb5cuVFIp7g== X-Google-Smtp-Source: AG47ELsSGAz3IQBuP/9hpJMPxKDV9IjcVqLOgl7gl/L5508SS4Zf98wnFRi6kCl4xVtLjAE5L0k1NA== X-Received: by 10.46.112.21 with SMTP id l21mr13172304ljc.45.1519851998355; Wed, 28 Feb 2018 13:06:38 -0800 (PST) Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id l8sm547134lfb.19.2018.02.28.13.06.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 13:06:37 -0800 (PST) From: Max Filippov To: qemu-devel@nongnu.org Date: Wed, 28 Feb 2018 13:06:12 -0800 Message-Id: <20180228210616.2756-8-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180228210616.2756-1-jcmvbkbc@gmail.com> References: <20180228210616.2756-1-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::244 Subject: [Qemu-devel] [PATCH 07/11] linux-user: fix target_mprotect/target_munmap error return values 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: Max Filippov , Riku Voipio , qemu-stable@nongnu.org, Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP target_mprotect/target_munmap return value goes through get_errno at the call site, thus the functions must either set errno to host error code and return -1 or return negative guest error code. Do the latter. Cc: qemu-stable@nongnu.org Cc: Riku Voipio Cc: Laurent Vivier Signed-off-by: Max Filippov --- linux-user/mmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index df81f9b803b6..84b15c9a1699 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -77,11 +77,11 @@ int target_mprotect(abi_ulong start, abi_ulong len, int prot) #endif if ((start & ~TARGET_PAGE_MASK) != 0) - return -EINVAL; + return -TARGET_EINVAL; len = TARGET_PAGE_ALIGN(len); end = start + len; if (!guest_range_valid(start, len)) { - return -ENOMEM; + return -TARGET_ENOMEM; } prot &= PROT_READ | PROT_WRITE | PROT_EXEC; if (len == 0) @@ -621,10 +621,10 @@ int target_munmap(abi_ulong start, abi_ulong len) start, len); #endif if (start & ~TARGET_PAGE_MASK) - return -EINVAL; + return -TARGET_EINVAL; len = TARGET_PAGE_ALIGN(len); if (len == 0 || !guest_range_valid(start, len)) { - return -EINVAL; + return -TARGET_EINVAL; } mmap_lock();