From patchwork Fri May 25 08:17:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 136795 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3281310lji; Fri, 25 May 2018 01:21:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ0G3YnpFdwr9NS2Zjeq5opX46r2NPOOjm5JZrHzNAwBVNsF6robBaEElPQS4qjkO9jC2Ne X-Received: by 2002:a0c:9487:: with SMTP id j7-v6mr1187987qvj.104.1527236508909; Fri, 25 May 2018 01:21:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527236508; cv=none; d=google.com; s=arc-20160816; b=efdk1dpD1c7YLQci7+qvE6hRI0fGXjcxSlnT07YyLeraaP8GaiR/QmNggaa+pxvBJS J85AAPTUdpJHn7QFlEY4MThBOQMu8fRAG4+5+AGlLJ+EcBjBSFMVfPMpNvyzqrk2/xkq HzRjDJoD82LAKbB110kU/vbCt0vLDcXeDBh5dgT2hCkworw/dG69fajSuMypunCi0Z/7 AKjA0DWIVj712O0GE+Jo3zC1lG5EZPsirUpvvM+UPbVjyHxtXPvhqX1Nyy3H1M0khl7S S3XDRjq6Ju+pe8gDIE/aehdKwF06H3dw1LuFJ5JxE6YFGuEEenoadjMVe3mE0yUjhJ7J w8mQ== 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:arc-authentication-results; bh=yu9WIVOLSsL4EV8n6Jk908gGJIYIXj8mO3fjOA99Am0=; b=fkBLo0MRCNPMl2PyJdJudy778M6z1TWkNVcgsPizGV/c/tEjtd1KXwNckW0aIJs8vr p2vFtbc2FvKAk2SeOXfstAxhBemUloqoVCSaxCl2BiiSzfto9lc9dRCTV/UaBqvkislA zh4K/HTia5yT+/ymspt/j0Ucfef/3O2lDBBB6mg2/yZZZBB66AVr2A0YDIXW59vHuyQR rLeXvha+JF4PyXjFkC4Oy1u5tbsykBK162y4BZZHXWe+sHH5DB3xjXGYkiWP38K3h6+U RsKZyhz0fqFH8J5fFIqGNk5CDEVfohIEI+4gYT4Q0p+teO5rXLVAlsYbDQF+Wf+VsUM0 YiqA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y186-v6si4685179qkc.405.2018.05.25.01.21.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 25 May 2018 01:21:48 -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; 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 Received: from localhost ([::1]:42394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fM7yu-0004Lz-Cy for patch@linaro.org; Fri, 25 May 2018 04:21:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fM7vd-0001lH-KJ for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fM7vX-0008F5-O0 for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:25 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:60651) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fM7vX-0008EJ-DY for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:19 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.183]) with ESMTPSA (Nemesis) id 0LrbAL-1gMNfI0Oy5-013NuC; Fri, 25 May 2018 10:18:09 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Fri, 25 May 2018 10:17:42 +0200 Message-Id: <20180525081754.29506-2-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180525081754.29506-1-laurent@vivier.eu> References: <20180525081754.29506-1-laurent@vivier.eu> X-Provags-ID: V03:K1:EU/HSOMjfadeVO+auwVzyo+R7ssl3LHVKei2xQIyQ6+lAf+WkeK KWTXeJyMeTbqkHjsphJvpqpZneeOggqzuYw2oSd722nth6BlksAlQqF0m/5LmTXDDpQvg/h zfF3VRdzlgybut6hRgtE1uE71vKFe1gSIsYnDo/B+qpWp4ZxqRWAEXCPaGQqUqmALY1DqQV ZetVrhW6cNilo+1JZnNQQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:jWBonskw4Ao=:O5qpbhZPTFsSGci1P2Kw0M Mqw7krdroS7zlJWLBR7Zs4TfvN+iz5U0H3k20nSQOZ9t6C/UyoJES8CRiEDut4dyS9iwVbOzm irqojWUp0VfpnZAstVa97EfcBZOmx6Rl/iTh/A8Cn1ouJ8d4rumKKCxOn8Jy8u/azvzA2qax0 vG7t9D/f4eT+T2jLeqpmQdJsAxVNiysoaGBSaZ1awwbZvEZgbjNYvgazOtz0gjciZeClbvf9f c8zht28m/jxPlIqIQEw5OJrvfUf+2tbfJmEaf4e/bhQkQCxv9RsCDLhokuerp7fRbkBaHAHFB Tnlcm+qXyveZB7pbHv4IL2+QMBBBHfNoRpQ1u8QcTdbylwAi5piwWXPZYo5S7YJGUWkPbgGEZ BpKwARRReSVoiytEDSlrHwEl1K7HYjNmW+LycBf3+Ns9VHjbBgazfkdvU2k6oPZqOr5TUShhY q7QCgAJGk9dwL/10MbKnkCTJKwj7nJUQW97EE1+mW5oRClUX7tc4PUVNc32uasR5/h6FRxphn O6RR/2u+ZIcrI8KPRpjikipfwP9p5ornb46AlB/Jn/Iltqt1EtMgOjCVwd//DR3ydAEELAkhw AMZrio0FccNLsrNNVDI5bXN+3uBZxxyso9kMuq4+djtqX7kwNAcTieTEXZgjC0kNdvgXvB5t2 i3IMkI7OCLVaBi1tdeGbztlC6VGDhSgRbFQ/oz0ePYb4VIofC1nFfXn7ekx6ZUZmsOi8= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.73 Subject: [Qemu-devel] [PULL 01/13] linux-user: Assert on bad type in thunk_type_align() and thunk_type_size() 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 , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell In thunk_type_align() and thunk_type_size() we currently return -1 if the value at the type_ptr isn't one of the TYPE_* values we understand. However, this should never happen, and if it does then the calling code will go confusingly wrong because none of the callsites try to handle an error return. Switch to an assertion instead, so that if this does somehow happen we'll have a nice clear backtrace of what happened rather than a weird crash or misbehaviour. This also silences various Coverity complaints about not handling the negative return value (CID 1005735, 1005736, 1005738, 1390582). Signed-off-by: Peter Maydell Reviewed-by: Laurent Vivier Message-Id: <20180514174616.19601-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- include/exec/user/thunk.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.14.3 diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h index 8f55b233b3..8d3af5a3be 100644 --- a/include/exec/user/thunk.h +++ b/include/exec/user/thunk.h @@ -135,7 +135,7 @@ static inline int thunk_type_size(const argtype *type_ptr, int is_host) se = struct_entries + type_ptr[1]; return se->size[is_host]; default: - return -1; + g_assert_not_reached(); } } @@ -185,7 +185,7 @@ static inline int thunk_type_align(const argtype *type_ptr, int is_host) se = struct_entries + type_ptr[1]; return se->align[is_host]; default: - return -1; + g_assert_not_reached(); } } From patchwork Fri May 25 08:17:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 136793 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3278686lji; Fri, 25 May 2018 01:18:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLFgTQSV5lYTvoItUnzizW42ZaW+DGoTV+3jbkfu4ewF1fD+XquZCbBIirgXycbwfdKijk5 X-Received: by 2002:a37:4041:: with SMTP id n62-v6mr1095466qka.287.1527236334522; Fri, 25 May 2018 01:18:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527236334; cv=none; d=google.com; s=arc-20160816; b=PY/diNI1Cb2hQc8VfV6nLPQQ9plmLEMAEKI6UV2HFS3N+CdjoMcNqq2LqjiA6169eG 0bilsy3DtyvQDKAVK+YiybBMXpbyuv5yZD98zs3ULrE68Z+9hD7J1Wg0uQRmTyCWjUt1 5PgRhZeMVvK9rC87QzqGpIQo1sMY3EaP5QnAG7gCKXoNBjkm64y6YwRGPQW+yJe/IVU4 9HFFP1bO2WTHtk+D5HRH1PUTu8AdrufC9SVIo7i6heWOpbNX2+Wb3vIHUk/GLWNRTx5t iHzy25079sg+bZVbjX8HKnuF7bDBUKPrrm4IlRfN52dKCdrLvGny3avMm+haTyPJcX0a Y4xA== 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:arc-authentication-results; bh=hUlZFw0Uk9koZGwK4cKkW9wTWvYz1oqRfTV+6DtT4cU=; b=PPG1OG+r1+BVMFml5u71xWQwrOoVBDr8nfp28tD2bW7s8q9utsj/YnFhCEHeF6Pn5M sZql1En3pqJhSANlKKd1UERgKhRgcyKeKwtO5rVA5kn1vraHCqKkHdvlbrMRgBFO+Q58 jrN1/NtZpFogrk7oArJOZON1RK2eSPvekJqG3qqSRHVwZjqaePhvZVOUDpIVw/H7TBkz aVrquWgOWz5PqXnmy1xhFECGE79a1KsgARxOLfuzEkOnczXlu3KtVFE++hGahO2QLgYL 2DjUtl1USd7qansb87p27NK+ezk2n2EsCmLYw5q3g6dewtPPUGaPWmQ8I/6w7Y4ko11I FDgA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v21-v6si7160061qtp.332.2018.05.25.01.18.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 25 May 2018 01:18:54 -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; 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 Received: from localhost ([::1]:42376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fM7w5-0001mj-U2 for patch@linaro.org; Fri, 25 May 2018 04:18:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fM7vc-0001kB-ND for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fM7vY-0008FW-DJ for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:24 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:32979) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fM7vY-0008Er-3V for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:20 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.183]) with ESMTPSA (Nemesis) id 0M2MnE-1gBc182MhI-00s9UX; Fri, 25 May 2018 10:18:10 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Fri, 25 May 2018 10:17:45 +0200 Message-Id: <20180525081754.29506-5-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180525081754.29506-1-laurent@vivier.eu> References: <20180525081754.29506-1-laurent@vivier.eu> X-Provags-ID: V03:K1:IbbJw5M6Y1RR3q3Xv7gDeApulJSgTNXh56P6/TcK5QAy6U4wBHl jTrWbwamv4D7w6CjEenGs042j8ZqmLaDFvtIJ22Cj5uXFHa6lzPcjZJDxU90yN5etr/b2Jv Cu0Wf8KK2LEqUDCBiLZlJbiVophutYyKE7J4HCjVq/Q7CVwPJZbmI7MlQ6qGqiYiBFZV/wV AIdGwDAdMZ0PbhrFTD6zw== X-UI-Out-Filterresults: notjunk:1; V01:K0:MNJF2hzXsxs=:EI1vn7HPiAFy3Zoyp22myx f0+Z9ra05qYGpOASqaW1NcZ3jWareF2Qe+o0xrvENYpuLEvkW2AsB7XQ9WtcAQiaJX6Lad5jE WDfrfq8IARwJi1hlBnXnvI42c/BknA0NZzbd7a/50sQTIcW9ssJ0BH2j70AzojJX6lNk5MsZ/ rR8iMbi5BCrhXv3X5OxB68iCEWG8C7RoxmALZuVizSYIGUgmsZnPVAppMvqDCqICWmqlgY/pm 2YyKzDxW/et/JPsyhAue8ceVLs6T2i0qgvDKiPPMRsJoc72AUjme7FkKYxo0IyvxJkQSJwgcG Wr35Oao0EcFGwMi6y3qmX6ha6X7dT1RzCD1cWfEEJ5cN4HNerzPuFL8G2v8eo+55irC6KEt5/ h5sB6ZJGtbzxVSTzziRDU0aidoiJNY67dJsrX/TzRXjRlWNdAMGk9/kEfJeYZpHy6799Jv01+ ocKrIOovX4ScP2aq73as/irk/H/xnOETYGbEzUBFaVu4Z3GXNBniUScuBaEeZPzDvbn4p+DF7 HIZ9b7/Dv6N1gqpietj1iTFvrY+2y6iZahAbe6xEdGQFvRZUIaNyyTfdgA6GrkbeUxg7Ki5st 2BT0t/F7iEXEzR2msIiXBWV5XqqDrRnVo3vr8HWMIXXyvaXaoPOnBUYAyMXfVKesy9VJ5oU8x p2XTCXy+wNsXOkZgckViK2zc2F3ctlWsuvuENTbPZYC3xhLtpAN+lfgGCzNlgrY9n1wE= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.75 Subject: [Qemu-devel] [PULL 04/13] linux-user: Fix payload size logic in host_to_target_cmsg() 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 , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Coverity points out that there's a missing break in the switch in host_to_target_cmsg() where we update tgt_len for cmsg_level/cmsg_type combinations which require a different length for host and target (CID 1385425). To avoid duplicating the default case (target length same as host) in both switches, set that before the switch so that only the cases which want to override it need any code. This fixes a bug where we would have used the wrong length for SOL_SOCKET/SO_TIMESTAMP messages where the target and host have differently sized 'struct timeval' (ie one is 32 bit and the other is 64 bit). Signed-off-by: Peter Maydell Reviewed-by: Laurent Vivier Message-Id: <20180518184715.29833-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.14.3 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index dd77f86ea2..d02c16bbc6 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1848,6 +1848,7 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh, /* Payload types which need a different size of payload on * the target must adjust tgt_len here. */ + tgt_len = len; switch (cmsg->cmsg_level) { case SOL_SOCKET: switch (cmsg->cmsg_type) { @@ -1857,8 +1858,8 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh, default: break; } + break; default: - tgt_len = len; break; } From patchwork Fri May 25 08:17:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 136794 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3280888lji; Fri, 25 May 2018 01:21:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIH22vSh5Pu48HqVZcG8Ozujtm/3BZNCPXr84uQGz1MNUbfH6VpGdyIsoIBjbZMK7r78uzi X-Received: by 2002:a0c:d911:: with SMTP id p17-v6mr658593qvj.78.1527236482791; Fri, 25 May 2018 01:21:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527236482; cv=none; d=google.com; s=arc-20160816; b=ijGpfVMLO6Pe4qN96Hk+0lRx81zqKQAxk963s3N4gjNRa9Qc6eJfm75YmBon3pPP9k hp3zk3IT1KhsRMO/qFs/bT5z5/lTeg5Hu3jqxWcZZ6Mflr1MpQ6FJYS8F4TwjsqGUeyy 3QbaXq7ixXIw40it+XP/GPV2B9C4JCstiH/An1maWCtOK+xM3iBpuShL5nbA1jiSCLcO 70xi/fRwsI+m/s39PKtS1v3UGe+IU3HA5mVLdBHkxY0PrkN/0KPwuOJsm4JxyVkwq05a 49lfUnnCzQc0l81yuhwrmi2pLXNlnE+TVSWkXc+zMb5kBFSNCJtbljv4upqZoDVUYrQR ytOw== 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:arc-authentication-results; bh=IkbwtITmIZhUySvU1guDTEllB8+wXAfPnGcDrwS30QE=; b=FAPShqepW/6ZzwamnaUqG8Vy6peVOcgXA73tNDOz3V/tc0tArHV/OCBBIBwSOgVII5 jAPF2vZLJeqeyIavAxIEnXLS0+neQDhIa/t8jFhsG2SrMJjjqbnJGM3mYrP1mQOoo5Bc Ky1em/j8yHPX7mDZw1DHp21+qeJMeHXPQ8yDkoSLbEn5O5GL7RhsG2Mjz3JnRYfZafiC Znws2GYBmnMx+NhcqAcWaTFq+3a6na3ERj+q/49x9uq6mJidt0b+x2R5Mpz790SN35DR O2LR1ya8x+MCSXwghQDDBZ0V5qL9DBy+zfR/8TSlrcI92VetY69nFMa4SSoawjFe/fjS guMg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g127-v6si13761361qkc.180.2018.05.25.01.21.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 25 May 2018 01:21:22 -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; 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 Received: from localhost ([::1]:42381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fM7yU-00031U-7w for patch@linaro.org; Fri, 25 May 2018 04:21:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fM7vd-0001kC-9x for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fM7vc-0008JW-4S for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:25 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:46505) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fM7vb-0008Ib-Rx for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:24 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.183]) with ESMTPSA (Nemesis) id 0M1WmX-1gEeQI0k0H-00tW0C; Fri, 25 May 2018 10:18:15 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Fri, 25 May 2018 10:17:54 +0200 Message-Id: <20180525081754.29506-14-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180525081754.29506-1-laurent@vivier.eu> References: <20180525081754.29506-1-laurent@vivier.eu> X-Provags-ID: V03:K1:mkqzhbzPzdx4UJnG6BOiGLKTbbO8OLfFPjb/ixsmFJa6OjDRrII EHNoXZ5qF1H3YXyIhSKtG4OfP2MMzKjin0Q9b8Coyp1A1xPTTVG2Q8U+/YKqSaqBLl6loCK AwMgoFo8KpoyrShf+fY46J6MI8eg5GCkmGo+VVCyT+CSsk0HloboOJtLw5jDX4XtfXFF6TF S73A/IR84oSo4WngIvxAg== X-UI-Out-Filterresults: notjunk:1; V01:K0:5/GcwrRraFc=:WU2Hb1CxXaBKns4uoQMxEc CnqrijvKUqB2s7utZQotMk1+X6GNjp5Jm7B8/YAuyI7k/TyxayKX+rRLwYwgSehib2Mb0MNUg bUio2iWSlqb2C1HqYoR1h8IRenH0LRdnp5cLak6qlVIDmW2KeC30h/it6zHyXslyD8aVKVXOM i1vLlXD0KrKOEh96tFZsZTnV67mTretNdN4ab9mOeHVpmmsBzZDztQGKXSSiQtCEWk9cL7l5Q 18WMb319xSwrbXiHDtznb7DSTk84jCF8k3a41kfmQyk1wS6Yb+WaJFkPaKKYxECb/9i8UZUnq 8hg6BHQ5J4lTNgwzJSg+ik/uJ2SVkvsVyF0M+DN9YAWtYpxJphd8ocA1bKBlVYofrrWp3MRD1 RselTdpkmMHewIM1+LKjHQ/o7d4SIMPDvJiAxBjDoXayoVQH6vL84YEAH3M89qQVHY0nlgR53 pqM8kFmW5og68Iiy69QQTcQZpfEw4Bp9emdEB2WP6sqH0njqYVxumtsOU+spHES1YyA9UvSqY lwDSxw+3QPcwXVyuwGV3rUJu21M07huBlLqwnEUxa0YllHzl4thYruYUfgNwrA15rjb9irHYV nE55cQ56HEc2vW2AxjE4PH+dH0UU/nOfmXAfF176vp6wBLU2qfSeMZkT5oLPO3uoPDsblJyic 8TtoRxY0bn+IxFxDj2uy/vViRZrD4I1urMkKqyvjNw5Bf9YDv/Y/o2jPlbOYuBJjh8BE= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.73 Subject: [Qemu-devel] [PULL 13/13] gdbstub: Clarify what gdb_handlesig() is doing 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 , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell gdb_handlesig()'s behaviour is not entirely obvious at first glance. Add a doc comment for it, and also add a comment explaining why it's ok for gdb_do_syscallv() to ignore gdb_handlesig()'s return value. (Coverity complains about this: CID 1390850.) Signed-off-by: Peter Maydell Message-Id: <20180515181958.25837-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- gdbstub.c | 6 ++++++ include/exec/gdbstub.h | 15 +++++++++++++++ 2 files changed, 21 insertions(+) -- 2.14.3 diff --git a/gdbstub.c b/gdbstub.c index e4ece2f5bc..6081e719c5 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1558,6 +1558,12 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va) *p = 0; #ifdef CONFIG_USER_ONLY put_packet(s, s->syscall_buf); + /* Return control to gdb for it to process the syscall request. + * Since the protocol requires that gdb hands control back to us + * using a "here are the results" F packet, we don't need to check + * gdb_handlesig's return value (which is the signal to deliver if + * execution was resumed via a continue packet). + */ gdb_handlesig(s->c_cpu, 0); #else /* In this case wait to send the syscall packet until notification that diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 2e8a4b83b9..08363969c1 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -48,6 +48,21 @@ int use_gdb_syscalls(void); void gdb_set_stop_cpu(CPUState *cpu); void gdb_exit(CPUArchState *, int); #ifdef CONFIG_USER_ONLY +/** + * gdb_handlesig: yield control to gdb + * @cpu: CPU + * @sig: if non-zero, the signal number which caused us to stop + * + * This function yields control to gdb, when a user-mode-only target + * needs to stop execution. If @sig is non-zero, then we will send a + * stop packet to tell gdb that we have stopped because of this signal. + * + * This function will block (handling protocol requests from gdb) + * until gdb tells us to continue target execution. When it does + * return, the return value is a signal to deliver to the target, + * or 0 if no signal should be delivered, ie the signal that caused + * us to stop should be ignored. + */ int gdb_handlesig(CPUState *, int); void gdb_signalled(CPUArchState *, int); void gdbserver_fork(CPUState *);