From nobody Sat May 18 20:37:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1713999129; cv=none; d=zohomail.com; s=zohoarc; b=NPB7ZFDD2y5TyqszIqTrWFl81uwYxNND+gMYJQhpOy2bFszTMgCjmwJQ2Z/y4LpGzsWcWzIrulX7iT8Dz+LYb18A9fS03SFIsr8B9kaQJ6r7i451tm7JyM8nx/HAGBc464DBKFXAJlmEJ/SYx6WCPQNZeY9/YfxoT+9Yhpkpb10= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713999129; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PIVpHaDvexJpR4v3VPoHT+wrjfi6nDMX3Dvh/TsygHY=; b=cCM7MrjBAFfXry2FcLxXWPeCVtrwrwiuV7sQRIOmO7cW6+mKehqWNHWhyDrxOBOcCfCULgyOi22NXdBET9E9esRK216mfx50pS9cYweyZ8i3l/6gqBUMxTbfiqmpIBBXLBEA7w6jNcho1KZic585bicghM6QnAz+Zm8R9up2OS0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713999129670400.90401444730037; Wed, 24 Apr 2024 15:52:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzlSd-0006wY-Qo; Wed, 24 Apr 2024 18:51:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzlSb-0006va-RG for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:29 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzlSZ-0006eh-VH for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:29 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6f074520c8cso493304b3a.0 for ; Wed, 24 Apr 2024 15:51:27 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id it12-20020a056a00458c00b006ead792b6f2sm11960864pfb.1.2024.04.24.15.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 15:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999086; x=1714603886; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PIVpHaDvexJpR4v3VPoHT+wrjfi6nDMX3Dvh/TsygHY=; b=r7kdj/pF1Y578nrjgawPvkKy0b/YSFTML2E9ZPBeF0flZklGUWYYRMpnh7jMpGMuGs xsKSdDQKVfbnRKmRSYoQw/NEryLFwRIJodynj+KPZDcq9jKOai2s6p/FztFLmutNbrmB PBuqXCoMe/RPr2A6vjIoWaqP42mCxNLhs6idSi2wlJf7N9To7NRziuDMT1CtH3xbGN7H x7hiuuf2vVKgod1IN5WLlPhIeNAwIuwlzqjQbQCY0fGxWftZQZgV3XKXfSL+NCm3g2SQ j+sDEPovn2AoZmHEXmpp4Muo8U4I598h60TxOYNkflRwL+dEF+yVywXAQsB7xVw+M6pV m0XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999086; x=1714603886; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PIVpHaDvexJpR4v3VPoHT+wrjfi6nDMX3Dvh/TsygHY=; b=cXkKaUNPXXKWIppX4hs0qzIbq+jB+SYP16D1pEx0GX3ptYZ049cjy/czZegdwPiHbF G8xD6Swivkaa5ewToxdxicQWXKW3u2GmTqQka/P5CUNwQKbPj9Do24PGYDdCJF+ng5S+ nWgY7uPhohVH/ARjv5rChnFkNFFBQvrUTiCw755hnTo9sKokdzLxu6jkn43sTWEdxFs3 uEYGHIgiag24lf3gCztZAmToA0j3aSpZOXrrNVB0OOg9G+DkSIGBLh5iHG+IBZ6G1+lj Ch6msWOUfLamCh2rvBpeJsMjGzFbaCDzJ5eQNwTwD5L3w0sq7LLND9ccl1GW89FLThfM WKLw== X-Gm-Message-State: AOJu0Yw2V6popKh6LafQdM81fRO4w62XC53+MBKowPYdlP7c/Mkp+Reu DQDgEMv5FQvKiLON87RZZ5CeIiUUq4i0qLF6/4x1trXIQrqEdz+jI3SMjMBJXIsS05sN6VaOcbA F X-Google-Smtp-Source: AGHT+IE5TOAgqILpleFGV0tPIY646V491UQ39WHGQ+PTWHXeI4ir64SsS/enJkV4YPu6GcAz897mjw== X-Received: by 2002:a05:6a21:1798:b0:1aa:5b05:7925 with SMTP id nx24-20020a056a21179800b001aa5b057925mr4339527pzb.4.1713999086497; Wed, 24 Apr 2024 15:51:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich Subject: [PULL 1/9] meson: Make DEBUG_REMAP a meson option Date: Wed, 24 Apr 2024 15:51:15 -0700 Message-Id: <20240424225123.929152-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424225123.929152-1-richard.henderson@linaro.org> References: <20240424225123.929152-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1713999130694100001 Content-Type: text/plain; charset="utf-8" From: Ilya Leoshkevich Currently DEBUG_REMAP is a macro that needs to be manually #defined to be activated, which makes it hard to have separate build directories dedicated to testing the code with it. Promote it to a meson option. Signed-off-by: Ilya Leoshkevich Message-Id: <20240312002402.14344-1-iii@linux.ibm.com> Signed-off-by: Richard Henderson --- meson.build | 4 ++++ bsd-user/qemu.h | 6 ++---- linux-user/qemu.h | 4 +--- linux-user/uaccess.c | 4 ++-- meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/meson.build b/meson.build index 95cee7046e..553b940999 100644 --- a/meson.build +++ b/meson.build @@ -2350,6 +2350,7 @@ config_host_data.set('CONFIG_DEBUG_GRAPH_LOCK', get_o= ption('debug_graph_lock')) config_host_data.set('CONFIG_DEBUG_MUTEX', get_option('debug_mutex')) config_host_data.set('CONFIG_DEBUG_STACK_USAGE', get_option('debug_stack_u= sage')) config_host_data.set('CONFIG_DEBUG_TCG', get_option('debug_tcg')) +config_host_data.set('CONFIG_DEBUG_REMAP', get_option('debug_remap')) config_host_data.set('CONFIG_LIVE_BLOCK_MIGRATION', get_option('live_block= _migration').allowed()) config_host_data.set('CONFIG_QOM_CAST_DEBUG', get_option('qom_cast_debug')) config_host_data.set('CONFIG_REPLICATION', get_option('replication').allow= ed()) @@ -4277,6 +4278,9 @@ if config_all_accel.has_key('CONFIG_TCG') endif summary_info +=3D {'TCG plugins': get_option('plugins')} summary_info +=3D {'TCG debug enabled': get_option('debug_tcg')} + if have_linux_user or have_bsd_user + summary_info +=3D {'syscall buffer debugging support': get_option('deb= ug_remap')} + endif endif summary_info +=3D {'target list': ' '.join(target_dirs)} if have_system diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 1b0a591d2d..8629f0dcde 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -22,8 +22,6 @@ #include "exec/cpu_ldst.h" #include "exec/exec-all.h" =20 -#undef DEBUG_REMAP - #include "exec/user/abitypes.h" =20 extern char **environ; @@ -437,7 +435,7 @@ static inline void *lock_user(int type, abi_ulong guest= _addr, long len, if (!access_ok(type, guest_addr, len)) { return NULL; } -#ifdef DEBUG_REMAP +#ifdef CONFIG_DEBUG_REMAP { void *addr; addr =3D g_malloc(len); @@ -461,7 +459,7 @@ static inline void unlock_user(void *host_ptr, abi_ulon= g guest_addr, long len) { =20 -#ifdef DEBUG_REMAP +#ifdef CONFIG_DEBUG_REMAP if (!host_ptr) { return; } diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 32cd43d9ef..4777856b52 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -4,8 +4,6 @@ #include "cpu.h" #include "exec/cpu_ldst.h" =20 -#undef DEBUG_REMAP - #include "exec/user/abitypes.h" =20 #include "syscall_defs.h" @@ -332,7 +330,7 @@ void *lock_user(int type, abi_ulong guest_addr, ssize_t= len, bool copy); /* Unlock an area of guest memory. The first LEN bytes must be flushed back to guest memory. host_ptr =3D NULL is explicitly allowed and does nothing. */ -#ifndef DEBUG_REMAP +#ifndef CONFIG_DEBUG_REMAP static inline void unlock_user(void *host_ptr, abi_ulong guest_addr, ssize_t len) { diff --git a/linux-user/uaccess.c b/linux-user/uaccess.c index 425cbf677f..27e841e651 100644 --- a/linux-user/uaccess.c +++ b/linux-user/uaccess.c @@ -14,7 +14,7 @@ void *lock_user(int type, abi_ulong guest_addr, ssize_t l= en, bool copy) return NULL; } host_addr =3D g2h_untagged(guest_addr); -#ifdef DEBUG_REMAP +#ifdef CONFIG_DEBUG_REMAP if (copy) { host_addr =3D g_memdup(host_addr, len); } else { @@ -24,7 +24,7 @@ void *lock_user(int type, abi_ulong guest_addr, ssize_t l= en, bool copy) return host_addr; } =20 -#ifdef DEBUG_REMAP +#ifdef CONFIG_DEBUG_REMAP void unlock_user(void *host_ptr, abi_ulong guest_addr, ssize_t len) { void *host_ptr_conv; diff --git a/meson_options.txt b/meson_options.txt index b5c0bad9e7..adc77bae0c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -85,6 +85,8 @@ option('plugins', type: 'boolean', value: false, description: 'TCG plugins via shared library loading') option('debug_tcg', type: 'boolean', value: false, description: 'TCG debugging') +option('debug_remap', type: 'boolean', value: false, + description: 'syscall buffer debugging support') option('tcg_interpreter', type: 'boolean', value: false, description: 'TCG with bytecode interpreter (slow)') option('safe_stack', type: 'boolean', value: false, diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 5ace33f167..0a29d35fdb 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -29,6 +29,7 @@ meson_options_help() { printf "%s\n" ' --enable-debug-graph-lock' printf "%s\n" ' graph lock debugging support' printf "%s\n" ' --enable-debug-mutex mutex debugging support' + printf "%s\n" ' --enable-debug-remap syscall buffer debugging suppo= rt' printf "%s\n" ' --enable-debug-stack-usage' printf "%s\n" ' measure coroutine stack usage' printf "%s\n" ' --enable-debug-tcg TCG debugging' @@ -294,6 +295,8 @@ _meson_option_parse() { --disable-debug-graph-lock) printf "%s" -Ddebug_graph_lock=3Dfalse ;; --enable-debug-mutex) printf "%s" -Ddebug_mutex=3Dtrue ;; --disable-debug-mutex) printf "%s" -Ddebug_mutex=3Dfalse ;; + --enable-debug-remap) printf "%s" -Ddebug_remap=3Dtrue ;; + --disable-debug-remap) printf "%s" -Ddebug_remap=3Dfalse ;; --enable-debug-stack-usage) printf "%s" -Ddebug_stack_usage=3Dtrue ;; --disable-debug-stack-usage) printf "%s" -Ddebug_stack_usage=3Dfalse ;; --enable-debug-tcg) printf "%s" -Ddebug_tcg=3Dtrue ;; --=20 2.34.1 From nobody Sat May 18 20:37:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1713999179; cv=none; d=zohomail.com; s=zohoarc; b=Q9FPziDe0kauLViSBkoUJsWfdcawtqerHiXpgYQuKzATP1Tnb4VpALkLCOBeOMzofq+5dyMRS8H/OlPzO2z/hodALgrrQhduIG/i8zw+ZShzQJzpYea3CzhbGQeOnyZ/Wuv05dl0CL6NWpvQC0IazHYbh+0oLw9VCQ46aoConSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713999179; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eljbs2yNGMGPnWHJwv7NSq5kkRuO1URzZsDZcIZtS6U=; b=YEn15cixn7zA6njTqEQ5jNj0cmVN59U11zVfydUzOv5GKwrr2GmnP66zXvN8ybsa5hJwsHvsC9NQ5LHTLl8U6duI/nXEXRWxGrwCTWV8SwyJeKyr/JJnkA0ur99u/JuXx+EmYtq03+ktzG0yjONFEUi+fokO4Ft14Wptd+ZfL/M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713999179964666.1947440954372; Wed, 24 Apr 2024 15:52:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzlSf-0006xQ-Lq; Wed, 24 Apr 2024 18:51:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzlSc-0006vk-Ft for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:30 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzlSa-0006f3-N9 for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:30 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6ed112c64beso427631b3a.1 for ; Wed, 24 Apr 2024 15:51:28 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id it12-20020a056a00458c00b006ead792b6f2sm11960864pfb.1.2024.04.24.15.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 15:51:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999087; x=1714603887; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eljbs2yNGMGPnWHJwv7NSq5kkRuO1URzZsDZcIZtS6U=; b=usK6UKzCb0VsgHONVjfFftPh6lKhjR/dE9mB5CHzE+wE04bVVvnjseD/cGMgCD30lk 0o7zo6FruHCExRFxVpGzabksn5XnfX6/OhHnyC2GXAS9+Z2RJ0bfOQ+nmyrRIjlO3YBV qbM8JHS1bsC1RHQsbVKI2mKeizEmp4/jSC0agJnT6VPU8L9JUl/VIc961QL9cE0kUHib 1mxB4MizoPORy2ED+lpOrs65d2PAzmqxsGX5hS0bp6SBuGRNM66Jr41Kor6YZZqKmL+p 4qziw7Bdp9DoyJgBQ3owTvBx0ieQNaFLaWChrtFrHvfnwVmbElujMgNLB/K/8+QzBznr Pc4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999087; x=1714603887; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eljbs2yNGMGPnWHJwv7NSq5kkRuO1URzZsDZcIZtS6U=; b=e/sWSAyg7byxafTUQQmWwJaFaexn5pnxozbXOlpjppEJgcK9QjYK/CnurPCYig+67f Aa0WKTf3e9A0EPMSwOe967bemaRjeZM9q7jIvHGtw/01Pkc2Gig0jcmXFZjwA80fNkeC Nc2S6NS5SudpiKfcarFoqulsQvr+VGmO+DBi7s7YZetAkqmgNjHYHDphSVfVIsN2I1xe K76e9fP/QaAUHmNfRwm0ez7Q2gu+J+O3rNUYVIodgWBEBq4uXAvkitmi/IT8ysyw3S1+ En+FShW45JWbgaGd0oh86yKcQih+P6HlrlDjDt4Ho2b2jHCL8GLziO7sxNWwG5n2pNRC jV1g== X-Gm-Message-State: AOJu0YxJsOpWXmlqtcyx4CZeRwag/y9tjLuFMTUU2l5V4jA7tngm7f/c 4GSl/2Ro2MYQJS3MaNdvXQrG1VweudDVIaGAZbNJU9TEGRaeCDhP6eIEN6XwzfNEwk1aSUH6J1V N X-Google-Smtp-Source: AGHT+IHEdI0+DvyCQQNVanodi94T+fv4VBJ70uSPR22vTZUPBJiIvxwprCzwvRSBMqvCqYf7yAH/SQ== X-Received: by 2002:a05:6a20:6a12:b0:1a3:7de2:12b6 with SMTP id p18-20020a056a206a1200b001a37de212b6mr4250188pzk.26.1713999087335; Wed, 24 Apr 2024 15:51:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Michael Tokarev Subject: [PULL 2/9] linux-user: do_setsockopt: fix SOL_ALG.ALG_SET_KEY Date: Wed, 24 Apr 2024 15:51:16 -0700 Message-Id: <20240424225123.929152-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424225123.929152-1-richard.henderson@linaro.org> References: <20240424225123.929152-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1713999180631100002 Content-Type: text/plain; charset="utf-8" From: Michael Tokarev This setsockopt accepts zero-lengh optlen (current qemu implementation does not allow this). Also, there's no need to make a copy of the key, it is enough to use lock_user() (which accepts zero length already). Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2197 Fixes: f31dddd2fc "linux-user: Add support for setsockopt() option SOL_ALG" Signed-off-by: Michael Tokarev Message-Id: <20240331100737.2724186-2-mjt@tls.msk.ru> Signed-off-by: Richard Henderson --- linux-user/syscall.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3df2b94d9a..59fb3e911f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2277,18 +2277,13 @@ static abi_long do_setsockopt(int sockfd, int level= , int optname, switch (optname) { case ALG_SET_KEY: { - char *alg_key =3D g_malloc(optlen); - + char *alg_key =3D lock_user(VERIFY_READ, optval_addr, optlen, = 1); if (!alg_key) { - return -TARGET_ENOMEM; - } - if (copy_from_user(alg_key, optval_addr, optlen)) { - g_free(alg_key); return -TARGET_EFAULT; } ret =3D get_errno(setsockopt(sockfd, level, optname, alg_key, optlen)); - g_free(alg_key); + unlock_user(alg_key, optval_addr, optlen); break; } case ALG_SET_AEAD_AUTHSIZE: --=20 2.34.1 From nobody Sat May 18 20:37:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1713999179; cv=none; d=zohomail.com; s=zohoarc; b=FG+Ik958TcNkkz/ortB9cZdl8NdQoFCzdjZqbgzV3jqOYqEzZ4zU57QYwjlw85nmpNUvZqRopb+jztBnZyfNeE7bAukBiz4I8nqBd+ySVGXQictZuruEWrIDRFiR5hrzAvex0sJxNuCm9+nHoeLrKoSw3IWI8oNDWwS5AcyDSPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713999179; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aRT5ReX6FfNpi8sInY8Erna9AcoUcJ+9OuBKDiXG1pU=; b=ZPK8pJ1iqZhdYHAN7av5+cS7UabLT3TFJSfTNjKA5fxgpJgaXa2U6WjwZ+F1oX3MO6MbZuf6I2n07iHOFfa/k1pdVG8xS0buwjnbvHrfovG1hEoyY/tS2tx+RGEMdg5tn0eaGslXHo5VeUAwBDV39iqGFvn00A+1sl1r5zM9tKs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713999179288967.3454708143998; Wed, 24 Apr 2024 15:52:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzlSe-0006wo-Pk; Wed, 24 Apr 2024 18:51:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzlSd-0006wD-7F for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:31 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzlSb-0006fH-Jq for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:30 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6f043f9e6d7so447691b3a.3 for ; Wed, 24 Apr 2024 15:51:29 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id it12-20020a056a00458c00b006ead792b6f2sm11960864pfb.1.2024.04.24.15.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 15:51:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999088; x=1714603888; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aRT5ReX6FfNpi8sInY8Erna9AcoUcJ+9OuBKDiXG1pU=; b=ZYvc565Ov5sPmas60DlESQLgkhQ2oQL+fMrxUUfdFbulH7qvJ+x6kELuo2YRSoOAzU 823JwHPCfhfsRojqhn82kdMMEhpX3zN+DmzyPuXHiGeuDSKki528ORXRL+goqF/8DVFW NzccURbvqNPbztkmKFMZRmsNhasQF2ad74RIpbZEzHPmm+0o9SSaNn98qTdHpDtBrkXb MOqKjz/1T5/W94fGwHtSvp508qJOZloSZxqlbowyX2ZTFuYdkcvR07Iia3kqpWTcw8F8 mdC4P1iBzu/Su5onPah6ppZ4G4qYWtXrnyFRcFXVOpUC7XlrJkB6/eQU+z789gi9UxsI sNnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999088; x=1714603888; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aRT5ReX6FfNpi8sInY8Erna9AcoUcJ+9OuBKDiXG1pU=; b=EM5t++AnWy0vzohuZumXWd6njQ1jKKb+HQzCURisdgpZbiUZeIoTm1QxeDxNf17UOQ MF3LGy7dc4uAmTBgoN8Q5wnOltbQXRG/l+Y+96vlHFmZDbzocoWl2RUBe5jbYimv5AyZ j7mE3MR51UjTHcfE1LOGxP4IyoMZZO1uANLgrOwsq/kPSnB9DrdCrajLvECUM9a5Ndni 9dgI1e2VTladRqI4Lw4krTNsO5fBURp8VyG2PuY+dkbYgI81Hj9XgPeALoTSaGGMcn3w jv8rCZtGacaDe9wS9srDywaswcy8F9idbWVptzGxpWDr6FNi5hngAdm9rpA8iCpyWIua VkfA== X-Gm-Message-State: AOJu0Yw+dSeez1xWj/NxVwKBMvNp4NCidkVr/x+JCYxWaoWCPmFBmdvn D8OblTAAALnRRASB+qeRvBbiw3P/irDts/ke/ncXSL9Zig7oVnhN0xacqSvd5nQnmhPEZUWcjp4 O X-Google-Smtp-Source: AGHT+IEzRWpJMH9y3KYChUNeXKu5ktJl6zedosbWkGaGEIqAm0WgOWcIEYfAyx4D2PK0lM+q4kaVPQ== X-Received: by 2002:a05:6a20:daaa:b0:1aa:5e75:d31f with SMTP id iy42-20020a056a20daaa00b001aa5e75d31fmr4467385pzb.16.1713999088291; Wed, 24 Apr 2024 15:51:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Michael Tokarev Subject: [PULL 3/9] linux-user: do_setsockopt: make ip_mreq local to the place it is used and inline target_to_host_ip_mreq() Date: Wed, 24 Apr 2024 15:51:17 -0700 Message-Id: <20240424225123.929152-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424225123.929152-1-richard.henderson@linaro.org> References: <20240424225123.929152-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1713999180618100001 Content-Type: text/plain; charset="utf-8" From: Michael Tokarev ip_mreq is declared at the beginning of do_setsockopt(), while it is used in only one place. Move its declaration to that very place and replace pointer to alloca()-allocated memory with the structure itself. target_to_host_ip_mreq() is used only once, inline it. This change also properly handles TARGET_EFAULT when the address is wrong. Signed-off-by: Michael Tokarev Message-Id: <20240331100737.2724186-3-mjt@tls.msk.ru> [rth: Fix braces, adjust optlen to match host structure size] Signed-off-by: Richard Henderson --- linux-user/syscall.c | 47 ++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 59fb3e911f..cca9cafe4f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1615,24 +1615,6 @@ static abi_long do_pipe(CPUArchState *cpu_env, abi_u= long pipedes, return get_errno(ret); } =20 -static inline abi_long target_to_host_ip_mreq(struct ip_mreqn *mreqn, - abi_ulong target_addr, - socklen_t len) -{ - struct target_ip_mreqn *target_smreqn; - - target_smreqn =3D lock_user(VERIFY_READ, target_addr, len, 1); - if (!target_smreqn) - return -TARGET_EFAULT; - mreqn->imr_multiaddr.s_addr =3D target_smreqn->imr_multiaddr.s_addr; - mreqn->imr_address.s_addr =3D target_smreqn->imr_address.s_addr; - if (len =3D=3D sizeof(struct target_ip_mreqn)) - mreqn->imr_ifindex =3D tswapal(target_smreqn->imr_ifindex); - unlock_user(target_smreqn, target_addr, 0); - - return 0; -} - static inline abi_long target_to_host_sockaddr(int fd, struct sockaddr *ad= dr, abi_ulong target_addr, socklen_t len) @@ -2067,7 +2049,6 @@ static abi_long do_setsockopt(int sockfd, int level, = int optname, { abi_long ret; int val; - struct ip_mreqn *ip_mreq; struct ip_mreq_source *ip_mreq_source; =20 switch(level) { @@ -2111,15 +2092,33 @@ static abi_long do_setsockopt(int sockfd, int level= , int optname, break; case IP_ADD_MEMBERSHIP: case IP_DROP_MEMBERSHIP: + { + struct ip_mreqn ip_mreq; + struct target_ip_mreqn *target_smreqn; + + QEMU_BUILD_BUG_ON(sizeof(struct ip_mreq) !=3D + sizeof(struct target_ip_mreq)); + if (optlen < sizeof (struct target_ip_mreq) || - optlen > sizeof (struct target_ip_mreqn)) + optlen > sizeof (struct target_ip_mreqn)) { return -TARGET_EINVAL; + } =20 - ip_mreq =3D (struct ip_mreqn *) alloca(optlen); - target_to_host_ip_mreq(ip_mreq, optval_addr, optlen); - ret =3D get_errno(setsockopt(sockfd, level, optname, ip_mreq, = optlen)); + target_smreqn =3D lock_user(VERIFY_READ, optval_addr, optlen, = 1); + if (!target_smreqn) { + return -TARGET_EFAULT; + } + ip_mreq.imr_multiaddr.s_addr =3D target_smreqn->imr_multiaddr.= s_addr; + ip_mreq.imr_address.s_addr =3D target_smreqn->imr_address.s_ad= dr; + if (optlen =3D=3D sizeof(struct target_ip_mreqn)) { + ip_mreq.imr_ifindex =3D tswapal(target_smreqn->imr_ifindex= ); + optlen =3D sizeof(struct ip_mreqn); + } + unlock_user(target_smreqn, optval_addr, 0); + + ret =3D get_errno(setsockopt(sockfd, level, optname, &ip_mreq,= optlen)); break; - + } case IP_BLOCK_SOURCE: case IP_UNBLOCK_SOURCE: case IP_ADD_SOURCE_MEMBERSHIP: --=20 2.34.1 From nobody Sat May 18 20:37:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1713999190; cv=none; d=zohomail.com; s=zohoarc; b=L/IfIPJMM8ucK7hO3TzTZa05pwQw/A6XhUHtAm7jVJPy1STbfVDzlFXj6xNdm/b3NmSB0kTsBb507+RjM4fGoRj2EOCPOAxJ48pLGKgQsHc5Bu6qEl1IuI4+Rf+hJVCb9xk1Vla55xjmdVcPrpObXG7Pmrzf6JagvylH4hgAwhw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713999190; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JI74xSWz9fuppvIeUIbROGR0F/ne9t6G9LvnZBioEes=; b=nBPe3nObIqb16yIQoUJ31WXAQDniEUNlhB8ySigmsw2zLO2sW2sRbC1hYw3549KkO3FpEG8EjtVCF8QKAHdqzb7LC0TT2fRlUJMAVppTpVdKf5feZ5LDE/lwsoSjYCQiKK+beyVua0YDnAdY/SJjIWRt7Nm65ML8d4BluVzE520= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713999190965496.19513297466744; Wed, 24 Apr 2024 15:53:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzlSe-0006wp-Sk; Wed, 24 Apr 2024 18:51:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzlSe-0006wg-4O for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:32 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzlSc-0006fj-Jd for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:31 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6ed04c91c46so440465b3a.0 for ; Wed, 24 Apr 2024 15:51:30 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id it12-20020a056a00458c00b006ead792b6f2sm11960864pfb.1.2024.04.24.15.51.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 15:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999089; x=1714603889; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JI74xSWz9fuppvIeUIbROGR0F/ne9t6G9LvnZBioEes=; b=vFFYISOWbkz8WiNiX8NK85XdoRJFaLvVP0UtTB/eC/2cdLyQBF+JDdRIQkgYVgIZte b0XS3NjHKPj07e6RFvp31rxsOQl8KKH68o/ImMi1UqKMYjnnq81O3+hrETts0otDg5tQ wbFvMC5Qqqsn35tTEMatqtUPjWTfqQa7j5xij+c3BSvIUf+IOzG9b9FMPMBDFZ3ymBAM DxcJn1+FRQM8IAyb8Sc1N1+L1cEJi/ydKuvia3rgSiwvqOOrXk0dAoqiF0gUTKniyrjO 17n5/wVQkr+0YhHWi+MoVDPw+aMdiMZay/rRdF+8QDd5yB04Bn/n4Sb7vVEyqxVegxfX eyHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999089; x=1714603889; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JI74xSWz9fuppvIeUIbROGR0F/ne9t6G9LvnZBioEes=; b=FWGLdJvnUl4q+2sySUphS7WnbNY7L4vGNmqxCd086WPUp4JiZvtQOeokBwhq6UkV6G 5ABhhQDTu4UU9QC45NFWkq9HSAeQ+09XEl2wtK1BrvVJWDsuGy0ygTUCS191jiD04VQB Xv6auRA9NmqEkLdmkeARiy6AWN5SjGDvvg5LY95S+aEhIBRSH7iPG8ADMC7cTQ1XrqLV zcC6vPXOfguHuSyxuaXHjhnhuilD3d2aPMzZ1N2ykw+bdK02sndqJCIdj29NeOYdgXu9 leuM1baJgH0FOrSNIs/iz9faWG7jOT60Gx1WtR0AQGHRNel5o+uGPSOZ3xevPQz+vE4g Shrg== X-Gm-Message-State: AOJu0YzX24+LGIDOVYq/4r6scZBZGegVgtbSizhI2LIxTzARYy9aJFi+ GbG7Q4vRf7xP4gonBRHIFtftzlF1Ry/Ht5wY/rvsmoAPNVS0LMsPk9pOINc8D9uBIr5/G88IKJP J X-Google-Smtp-Source: AGHT+IExAPxa7FlTzJEu7qVqPW+srTBf6nmeVL0NH1/UaH1bC49s+Z/VgT8P91AmLXA7p82GBHSSGw== X-Received: by 2002:a05:6a00:190c:b0:6ea:8793:6d64 with SMTP id y12-20020a056a00190c00b006ea87936d64mr4605726pfi.23.1713999089139; Wed, 24 Apr 2024 15:51:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Michael Tokarev Subject: [PULL 4/9] linux-user: do_setsockopt: make ip_mreq_source local to the place where it is used Date: Wed, 24 Apr 2024 15:51:18 -0700 Message-Id: <20240424225123.929152-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424225123.929152-1-richard.henderson@linaro.org> References: <20240424225123.929152-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1713999192611100007 Content-Type: text/plain; charset="utf-8" From: Michael Tokarev Signed-off-by: Michael Tokarev Message-Id: <20240331100737.2724186-4-mjt@tls.msk.ru> Signed-off-by: Richard Henderson --- linux-user/syscall.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index cca9cafe4f..1fedf16650 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2049,7 +2049,6 @@ static abi_long do_setsockopt(int sockfd, int level, = int optname, { abi_long ret; int val; - struct ip_mreq_source *ip_mreq_source; =20 switch(level) { case SOL_TCP: @@ -2123,6 +2122,9 @@ static abi_long do_setsockopt(int sockfd, int level, = int optname, case IP_UNBLOCK_SOURCE: case IP_ADD_SOURCE_MEMBERSHIP: case IP_DROP_SOURCE_MEMBERSHIP: + { + struct ip_mreq_source *ip_mreq_source; + if (optlen !=3D sizeof (struct target_ip_mreq_source)) return -TARGET_EINVAL; =20 @@ -2133,7 +2135,7 @@ static abi_long do_setsockopt(int sockfd, int level, = int optname, ret =3D get_errno(setsockopt(sockfd, level, optname, ip_mreq_s= ource, optlen)); unlock_user (ip_mreq_source, optval_addr, 0); break; - + } default: goto unimplemented; } --=20 2.34.1 From nobody Sat May 18 20:37:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1713999132; cv=none; d=zohomail.com; s=zohoarc; b=LXU/bB5qcY+SKnqjrdvZQ7xfBDlXBAeNbbtIBEoowjHH0AE3cm6vsiR9Q6fvd2n+FMWtWgS1mmXZH3/png70M/R0jjgRPmqV9ufwrVB4HsWE/F+uKkGroscrS462j+SDvHmxJqsVVfKhfn6Iu10udUJJyy8xUb8VX4D3b8UGFWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713999132; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/Qew14nZN1wX0iqwNUmvetvShYAajmyZbQ1f420VzBg=; b=QXuD0DAneTtaTFhZgRIEueg8fmFYtrf9BwXu8tptzj2sL9ahSDGK+BcZ1g1e2ewItG41+4zMH4vok6kAHXottbcdfUk4xqyKwp7OsY/QHcsKh/ajArXmX/Mf31Jlt+XnrJTTffVNuqTbl50A+gf3khrUrjPaMUpPFP7fLqLzAVw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713999132292992.2514199159555; Wed, 24 Apr 2024 15:52:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzlSg-0006xl-MT; Wed, 24 Apr 2024 18:51:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzlSf-0006wr-4C for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:33 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzlSd-0006g3-IV for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:32 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6ece8991654so434410b3a.3 for ; Wed, 24 Apr 2024 15:51:31 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id it12-20020a056a00458c00b006ead792b6f2sm11960864pfb.1.2024.04.24.15.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 15:51:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999090; x=1714603890; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/Qew14nZN1wX0iqwNUmvetvShYAajmyZbQ1f420VzBg=; b=Nl1fYlMg5DMZGTM4O5nY49rVIm2dm68dYtvBjqjcSAYKaSMH4NbpzfsdtdQI+U8clA yfX6tXaEqyWOqvlxPeM6IhHDFPJnV+b/IMu+mmaDwHzVlDDoWayIHTs3O2OZFqnvsO0C b6MAmSlFE1AzUm7TXSji8YhoRRr8z0kmplehgVxAC5o9bjyXHfBbMxbheMqHkLcYjuSf XffCEO3isocEdoB3G7RzF+p7VrSHByjWGv3C/s3IUIbCFnbpOf4FpAkdKurf5KSAxm1v kB8rmZdcwvk4dFzQxP6Xtqh7mNJk5TeDUpDqWUlZmmP7BAk2wrsdsprwkJ1okUbj3RFX piWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999090; x=1714603890; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/Qew14nZN1wX0iqwNUmvetvShYAajmyZbQ1f420VzBg=; b=kMIoWo4+Juw69xsPyqiXfhXxaDyh8eSu5zPzVBPkhGxyTVKKf/6pxkoBDWQGEi0lQu YFIDmJvcVETCVREDP2S8e6YG8cq0OC2j5diLtUy4oXmIkjFa81mEy8cga3iO7bAs4pTY II2yUwU0YQGVlmksRcVJmzTQ/6ZW3G3Q9CabgoC8kB6ZHImE3ajPXLPPofHjhr/1Uuf+ 7+b9NUt8oHTBaCXsKn73oo8cD+9c1hLlBTr4Wp5+LUmcpfS6nt15LC/HfzgOSmpvzB54 KOTseUyBQA2yeLksIWPdcnXLT/D47NCrLuvUC+nGknSofCU9TmGzyRrLoYx6DNVlULcc wYIw== X-Gm-Message-State: AOJu0YzvV0PSYoxI/Yp0rTOEKjiy6IH87zoFMCecdRHXtjDmhi+jN77/ f2IWNa2h0Is8jqBsJQmTSd81luN5VUGoc6TImzWjAYJcOGWfamybvrOH2DenWURARD4cIkXYmvY K X-Google-Smtp-Source: AGHT+IFJAHrL3Kwrpi0ZJ2frFe2ZJ5teqk8ugDlLfhbu1sBJuuZ0Sp97UdCzx6kKiaJ7qk2Va8/dDQ== X-Received: by 2002:a05:6a21:6d9c:b0:1a7:3d2a:7383 with SMTP id wl28-20020a056a216d9c00b001a73d2a7383mr5517735pzb.18.1713999090209; Wed, 24 Apr 2024 15:51:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 5/9] linux-user: do_setsockopt: eliminate goto in switch for SO_SNDTIMEO Date: Wed, 24 Apr 2024 15:51:19 -0700 Message-Id: <20240424225123.929152-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424225123.929152-1-richard.henderson@linaro.org> References: <20240424225123.929152-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1713999132493100005 From: Michael Tokarev There's identical code for SO_SNDTIMEO and SO_RCVTIMEO, currently implemented using an ugly goto into another switch case. Eliminate that using arithmetic if, making code flow more natural. Signed-off-by: Michael Tokarev Message-Id: <20240331100737.2724186-5-mjt@tls.msk.ru> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/syscall.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1fedf16650..41659b63f5 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2301,12 +2301,10 @@ static abi_long do_setsockopt(int sockfd, int level= , int optname, case TARGET_SOL_SOCKET: switch (optname) { case TARGET_SO_RCVTIMEO: + case TARGET_SO_SNDTIMEO: { struct timeval tv; =20 - optname =3D SO_RCVTIMEO; - -set_timeout: if (optlen !=3D sizeof(struct target_timeval)) { return -TARGET_EINVAL; } @@ -2315,13 +2313,12 @@ set_timeout: return -TARGET_EFAULT; } =20 - ret =3D get_errno(setsockopt(sockfd, SOL_SOCKET, optname, + ret =3D get_errno(setsockopt(sockfd, SOL_SOCKET, + optname =3D=3D TARGET_SO_RCVTIMEO ? + SO_RCVTIMEO : SO_SNDTIMEO, &tv, sizeof(tv))); return ret; } - case TARGET_SO_SNDTIMEO: - optname =3D SO_SNDTIMEO; - goto set_timeout; case TARGET_SO_ATTACH_FILTER: { struct target_sock_fprog *tfprog; --=20 2.34.1 From nobody Sat May 18 20:37:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1713999161; cv=none; d=zohomail.com; s=zohoarc; b=neTjqpkrWLnL+4y8pd6S1n1JyBuTh4H31lvRefnwoptBzkoLiNLLRWL2SmZwUVLDrWvBDVhV4SZEfnCWejV0QPfXRW/FOhVXLZkvli1Vj1XyseAZqdyv+ZHUrbTSJTVJ8VktPEefQMsdGkKTni9shQGI+66/+6IQkrz9tNgsvA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713999161; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UDr6R2ma44jwvkJI3Qs5id/WJ2z4/lQ44GztsnjZcyw=; b=RPkdmZU/6G2YI6wqHSazhRKLYpeu6MUUFgDPVRJ8pgoQ1fKYpFO4O3zuTMFNu+vxXyBd3JDbFNH2lBHNQfEKsapExeCBlcLlUoHjIxnU0/6ptuuSz7hTsWlK7EgTEA1M1+VrFeWyNubzWcWUX/BPOBxokBLha0+h7Ac1AQ8u7T0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713999161111702.2178943464321; Wed, 24 Apr 2024 15:52:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzlSh-0006y8-FL; Wed, 24 Apr 2024 18:51:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzlSg-0006xk-IO for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:34 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzlSe-0006gJ-MJ for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:34 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6ecf05fd12fso408927b3a.2 for ; Wed, 24 Apr 2024 15:51:32 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id it12-20020a056a00458c00b006ead792b6f2sm11960864pfb.1.2024.04.24.15.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 15:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999091; x=1714603891; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UDr6R2ma44jwvkJI3Qs5id/WJ2z4/lQ44GztsnjZcyw=; b=M+6bxgx24/yGZb2/YF5Kgwo/p7qWkjo599pFHECqFoFZ06u/7GIeXkySB5tJnnycNx xaLDHGGo15F502rCTDUJcIKRlmnawWIaYRSTSY7z4UDLsrtRbNwHXF/ftM9FautDS8Xp t1MhxOqf8trJbHI/+JTBdsNnH5BycRM4JIjBqmecjKyExL6oQYoK6dQYBm3qVyg1dd44 4+yjQWcbp52DsEI3RlP9LfZce2bM2tQIdGuVCbPUFWw3/7X0lcSA4sxF0gPcgSm3FR2Z oYMpKOjkXj7PYQw2QJOSsHowumXf5WKOhKrLcUAhBsNK4G0aU5wBo3Rkj/RNnKsDtQun aFMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999091; x=1714603891; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UDr6R2ma44jwvkJI3Qs5id/WJ2z4/lQ44GztsnjZcyw=; b=FUdujB6c/lA7rUH04LGxmzBocyi5nFcZ/+W5p5grNEvwgxkIizVagspJnpxCu7IAlb gbX/6p0C0JCs8Dbe9MG/1QRX503NUth/SjZ2eO4mkiYAhPjjlwj2eBr6mNTAd1fC7Y1n Ec8BfpCDGO+a1m1Mc4cAVA+hXvlSSzxjM9IgxObVv7Pywo/9uUd/EIXbhptX/6USTgtd nTQpwN/EUtXlw3Nn/SVd1JsbDPcYSwPUD3VaetyjNoekRllWaAbJIgAzqTQMAvIxZJ9U fpr75YndaqWtiCUwhReXBVQfBnXz7esojcQ3+ogzTk1RvH4Obddwzyy/rDgoq8q0PUef W83g== X-Gm-Message-State: AOJu0YwxWcXuq4D02omQycbAIWsmlI3YG3fqiPLkbdrN+XVTSql8vHaU fv6W4o9AVaY31DK9e6OfZhAS1eQnURA5DRFuSxsKHenpI+KJyhBsFt2hhtjJSuXB+AKRPUu08Sv E X-Google-Smtp-Source: AGHT+IHytaQk4tIr2c0NQEtKdGTfvZV+Bmq00AG3grIhMNYz5sA8mQWgN5bNTYxC0812lBG4GprxDw== X-Received: by 2002:a05:6a20:daaa:b0:1aa:5e75:d31f with SMTP id iy42-20020a056a20daaa00b001aa5e75d31fmr4467488pzb.16.1713999091197; Wed, 24 Apr 2024 15:51:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Michael Vogt Subject: [PULL 6/9] linux-user: Add FITRIM ioctl Date: Wed, 24 Apr 2024 15:51:20 -0700 Message-Id: <20240424225123.929152-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424225123.929152-1-richard.henderson@linaro.org> References: <20240424225123.929152-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1713999162598100001 Content-Type: text/plain; charset="utf-8" From: Michael Vogt Tiny patch to add the missing FITRIM ioctl. Signed-off-by: Michael Vogt Message-Id: <20240403092048.16023-2-michael.vogt@gmail.com> Signed-off-by: Richard Henderson --- linux-user/ioctls.h | 3 +++ linux-user/syscall_defs.h | 1 + linux-user/syscall_types.h | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 1aec9d5836..d508d0c04a 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -140,6 +140,9 @@ #ifdef FITHAW IOCTL(FITHAW, IOC_W | IOC_R, TYPE_INT) #endif +#ifdef FITRIM + IOCTL(FITRIM, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_fstrim_range))) +#endif =20 IOCTL(FIGETBSZ, IOC_R, MK_PTR(TYPE_LONG)) #ifdef CONFIG_FIEMAP diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 3995487630..a00b617cae 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -945,6 +945,7 @@ struct target_rtc_pll_info { =20 #define TARGET_FIFREEZE TARGET_IOWR('X', 119, abi_int) #define TARGET_FITHAW TARGET_IOWR('X', 120, abi_int) +#define TARGET_FITRIM TARGET_IOWR('X', 121, struct fstrim_range) =20 /* * Note that the ioctl numbers for FS_IOC_ diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index c3b43f8022..6dd7a80ce5 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -341,6 +341,11 @@ STRUCT(file_clone_range, TYPE_ULONGLONG, /* src_length */ TYPE_ULONGLONG) /* dest_offset */ =20 +STRUCT(fstrim_range, + TYPE_ULONGLONG, /* start */ + TYPE_ULONGLONG, /* len */ + TYPE_ULONGLONG) /* minlen */ + STRUCT(fiemap_extent, TYPE_ULONGLONG, /* fe_logical */ TYPE_ULONGLONG, /* fe_physical */ --=20 2.34.1 From nobody Sat May 18 20:37:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1713999189; cv=none; d=zohomail.com; s=zohoarc; b=lNu+4X2Qb0t7pobtljQUuNjoOffb8O4YcuKRl5I4NZ2nUcznNiSez9N76kMoZvE1yKOhcAtViCTMeofE+8Vr1Pkb4LxEDCjWvRK3k7nCQ5PMJFjp77a4+M7MYuoDOFt5ZXdkBzzIZNXBXE2M9syYzxtf6n3I5RvQ8z7XNpjV8Ow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713999189; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hIaIEQSm9VCOv6FXtjW2b8GU4ZH5b2a473JIJYHIFaQ=; b=XqVgEC3VVQQJvr2Fez78Z2CQPY0iS6rrdhR9598Ip/tmsEleoQ1ck+dfzTx+gbC8LoUyuG84m/zgdXU4vtUIzNw1TCWTSZw6FvuYyl2nF9N81texQLa1J2SU5UfbSNGDtjhL6RiIERve0PhvWuETeSAfAywya9L0U5vLjn/e4TA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713999189518815.388014150593; Wed, 24 Apr 2024 15:53:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzlSj-0006yo-Ah; Wed, 24 Apr 2024 18:51:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzlSh-0006y9-JK for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:35 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzlSg-0006gf-0H for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:35 -0400 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-60275a82611so308014a12.1 for ; Wed, 24 Apr 2024 15:51:33 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id it12-20020a056a00458c00b006ead792b6f2sm11960864pfb.1.2024.04.24.15.51.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 15:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999092; x=1714603892; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hIaIEQSm9VCOv6FXtjW2b8GU4ZH5b2a473JIJYHIFaQ=; b=B8pj1X+uCGrkrMLRzjaKrI0i7tliJ1bm0K8dIAxN3sEHU3m4UBtUyq7OruVwa2kgaA YiJpWBnp8tj0p0stOA54Lvp5akbesHWtSIiyXAlAocSkCsSb2YHraZqbWn3d/wUcV/Zx nklwjXawCb6443eydVtxI/m7o7pD0JCgRlG/dytJkWiasFK7jR8DcylUy7u4KDxLS7NV 8aZjUzqV1eyfS6ejMTto+Bhg9Q7IRcSSrrKpBRK/AOAEyVmdOw+UBCGuaXUT+Zc2Gxpg Swe87zIY24U2VpE2GqhYLRPH4dM20pMbUyZWXLFJyE2O2aurHMRsXU88oOimJZrtCWvL whbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999092; x=1714603892; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hIaIEQSm9VCOv6FXtjW2b8GU4ZH5b2a473JIJYHIFaQ=; b=psmMQJj0Roh83xEh/k1Uj8NBIzi3jIwa5iyodU8zuHo+mukm7UDUDNbtFb+OO+YB0y 6gBlRpK48Eknl8ORZEnbcM0WdF0BpP9yz6i4q/6gfuiFROvi4THELX3CbUKwTkmTfE8W zOor3U7QgZsDWp/KEy9mAESpRCKxTl1fHUavgxZWR49hTtzM4aOnAZXprQS0/xdzq/Id P1UfrSprScaAZ+pUD/f1FpHfAc23Nh0IiEeBD6Oasq2kV+R+ugxM/aGAH0rnLVaLLzC1 4bwj6nCaR1rY9eLAdfUigr5b+7yRv8iFpcmrSLtZalQq/f2bIjiWkKgqjwJmwLLe02lh 5wtQ== X-Gm-Message-State: AOJu0YwCXd6nPBd1w+PgPj8vYBjEtKzG+HnGj38RW4EuMnHQca6QLYpt dou7yHgA3tBvENltC1BVyMHC2iqkdn0pvxzmEZHnxXJ7CZ9d59MZVJ3sE3NEaRFRTkoxZJouv1w N X-Google-Smtp-Source: AGHT+IGiGpxbEZw2DQTNv1bxlxlGPhFndE2Eurw+VvK1IWTgmhiEcE1OttuHVKnQAf0En7W1X+SDaQ== X-Received: by 2002:a05:6a20:5605:b0:1a7:a564:14db with SMTP id ir5-20020a056a20560500b001a7a56414dbmr3990710pzc.24.1713999092294; Wed, 24 Apr 2024 15:51:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Keith Packard , Peter Maydell Subject: [PULL 7/9] target/m68k: Pass semihosting arg to exit Date: Wed, 24 Apr 2024 15:51:21 -0700 Message-Id: <20240424225123.929152-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424225123.929152-1-richard.henderson@linaro.org> References: <20240424225123.929152-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1713999190623100001 Content-Type: text/plain; charset="utf-8" From: Keith Packard Instead of using d0 (the semihost function number), use d1 (the provide exit status). Signed-off-by: Keith Packard Reviewed-by: Peter Maydell Message-Id: <20230802161914.395443-2-keithp@keithp.com> Signed-off-by: Richard Henderson --- target/m68k/m68k-semi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c index 546cff2246..6fbbd140f3 100644 --- a/target/m68k/m68k-semi.c +++ b/target/m68k/m68k-semi.c @@ -132,8 +132,8 @@ void do_m68k_semihosting(CPUM68KState *env, int nr) args =3D env->dregs[1]; switch (nr) { case HOSTED_EXIT: - gdb_exit(env->dregs[0]); - exit(env->dregs[0]); + gdb_exit(env->dregs[1]); + exit(env->dregs[1]); =20 case HOSTED_OPEN: GET_ARG(0); --=20 2.34.1 From nobody Sat May 18 20:37:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1713999146; cv=none; d=zohomail.com; s=zohoarc; b=I+nMnUmDcjMRpPIGYp9HYsY8ASqA5Kwy8bK4jy/Kt3rNPMVBRzuIjPbCCkDOOpkHDS3AIzcHZnAVOz+RruG4ALFivbzAwQtdoX+xVxdqcQjI9q/v8dwEik65YzEyL/ZlpzkSlW+uHLN8X4GMn2vKVklVNH1LWO0vl/5qrPc9Wd8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713999146; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=N1Fb/iLBacLjG+JYW3VIwBtHrdP9tAIF5ogLnK/WoGA=; b=M/Efw3XpGnf2+mJ9XJxyRBIb73two1kol2CNUAY5bGWUWJpkegiwDyl9ezTTQtop1M0xOl8xMQ7DPavCS2LJHW+8hgLDqPYOLZVtl8+XWuGCRmUPgYPnkTrJtpib7Pkr25pBYDJb0znEazGi0O+dsOz1v3WuYgSL01FsKqZSxQY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713999146513980.9775024019359; Wed, 24 Apr 2024 15:52:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzlSk-00070t-4m; Wed, 24 Apr 2024 18:51:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzlSi-0006yM-E4 for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:36 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzlSg-0006h3-K5 for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:36 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6ee0642f718so1140591b3a.0 for ; Wed, 24 Apr 2024 15:51:34 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id it12-20020a056a00458c00b006ead792b6f2sm11960864pfb.1.2024.04.24.15.51.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 15:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999093; x=1714603893; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=N1Fb/iLBacLjG+JYW3VIwBtHrdP9tAIF5ogLnK/WoGA=; b=gXL7aYadEgiP2R7/QB5RSLbcPfaEMqT0uSwshd+3qtx3EVwMGft3oW0Qc6GSZpRtor 4XAH8PS/1o69MvDZH2xVP8Zil1lcoAE26fxhNQi384GW1mOU7U8W6wm6G8REQy9FX+E/ 5IcbwEtjKgY3Z0qrloB7FczCj2CTB02Y5EGsDt3IosB+OWRhkZfWtAt7HebEiuBaD+XI 0VY0jwhjt4i2/qWgbDusqm9RcySHfw322k/CMqJQLLKauEHZ4ww6cyzDvKWENtfhxxG1 kOCTK32P9iQlf/GV15MS1otRwvQFGSS1sIUytVoJw4HfXMG/3OC1TqvYS6LQF/6LUiLG ckYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999093; x=1714603893; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N1Fb/iLBacLjG+JYW3VIwBtHrdP9tAIF5ogLnK/WoGA=; b=nYqZ0vqakZmv8m5PePkiaB3RanK0U7VcN6pkXVBJkGcW0V+4ltWOEKTAg+c8k7ldsC 2Md2eZ1jNaKqME8QAk6f7WQ1PbIEMNV85yhrorj39PyeUG1etQotWeJGRwwEmveU0rtv A2eLIzoZEAvl6W7OfrtV2vcsoyaKcYkRjylUM7R7kGTmEtBi1WXZ5f4v9ughi7O4+PHh hjIwUokk385Bs4Uc+FYodvXBUF4IMGM7b8Z4cfblEYZAJHw7hKUJOmFKWTetVF9LSsLV nR9jL2f6ymY8I+DTKxo67V00fzBRzGj0Ql87aSphoHKWoiMvdPYfr2diNYy4QNw8V6VN 318w== X-Gm-Message-State: AOJu0YxvPI6ZnguqeMGCy3YWMEfOaa6BQRfZBOTJQQIMuVcby1yzYHxb 5SvJBwZybC9QTjATyyWKRx//+eQc+Mw3tbP+A9Q+z9inDymT0feecCixv+Bo7EWUDSvr6ln+7Nf 1 X-Google-Smtp-Source: AGHT+IFfbmk//iNHRmpl0Jb3mZsOIbCi2khvtXpct3hGDCdjI6bkGhfNcPuGIKEcEyY7h/GqlEF1zQ== X-Received: by 2002:a05:6a20:9190:b0:1a9:9839:f142 with SMTP id v16-20020a056a20919000b001a99839f142mr1675127pzd.10.1713999093218; Wed, 24 Apr 2024 15:51:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 8/9] target/m68k: Perform the semihosting test during translate Date: Wed, 24 Apr 2024 15:51:22 -0700 Message-Id: <20240424225123.929152-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424225123.929152-1-richard.henderson@linaro.org> References: <20240424225123.929152-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1713999148556100003 Content-Type: text/plain; charset="utf-8" Replace EXCP_HALT_INSN by EXCP_SEMIHOSTING. Perform the pre- and post-insn tests during translate, leaving only the actual semihosting operation for the exception. Signed-off-by: Richard Henderson --- target/m68k/cpu.h | 2 +- target/m68k/op_helper.c | 14 ++----------- target/m68k/translate.c | 45 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 44 insertions(+), 17 deletions(-) diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index e184239a81..b5bbeedb7a 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -66,7 +66,7 @@ #define EXCP_MMU_ACCESS 58 /* MMU Access Level Violation Error */ =20 #define EXCP_RTE 0x100 -#define EXCP_HALT_INSN 0x101 +#define EXCP_SEMIHOSTING 0x101 =20 #define M68K_DTTR0 0 #define M68K_DTTR1 1 diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c index 125f6c1b08..15bad5dd46 100644 --- a/target/m68k/op_helper.c +++ b/target/m68k/op_helper.c @@ -202,18 +202,8 @@ static void cf_interrupt_all(CPUM68KState *env, int is= _hw) /* Return from an exception. */ cf_rte(env); return; - case EXCP_HALT_INSN: - if (semihosting_enabled((env->sr & SR_S) =3D=3D 0) - && (env->pc & 3) =3D=3D 0 - && cpu_lduw_code(env, env->pc - 4) =3D=3D 0x4e71 - && cpu_ldl_code(env, env->pc) =3D=3D 0x4e7bf000) { - env->pc +=3D 4; - do_m68k_semihosting(env, env->dregs[0]); - return; - } - cs->halted =3D 1; - cs->exception_index =3D EXCP_HLT; - cpu_loop_exit(cs); + case EXCP_SEMIHOSTING: + do_m68k_semihosting(env, env->dregs[0]); return; } } diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 8a194f2f21..647bd9d9be 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -26,12 +26,11 @@ #include "qemu/log.h" #include "qemu/qemu-print.h" #include "exec/translator.h" - #include "exec/helper-proto.h" #include "exec/helper-gen.h" - #include "exec/log.h" #include "fpu/softfloat.h" +#include "semihosting/semihost.h" =20 #define HELPER_H "helper.h" #include "exec/helper-info.c.inc" @@ -1401,6 +1400,40 @@ static void gen_jmp_tb(DisasContext *s, int n, targe= t_ulong dest, s->base.is_jmp =3D DISAS_NORETURN; } =20 +#ifndef CONFIG_USER_ONLY +static bool semihosting_test(DisasContext *s) +{ + uint32_t test; + + if (!semihosting_enabled(IS_USER(s))) { + return false; + } + + /* + * "The semihosting instruction is immediately preceded by a + * nop aligned to a 4-byte boundary..." + * The preceding 2-byte (aligned) nop plus the 2-byte halt/bkpt + * means that we have advanced 4 bytes from the required nop. + */ + if (s->pc % 4 !=3D 0) { + return false; + } + test =3D translator_lduw(s->env, &s->base, s->pc - 4); + if (test !=3D 0x4e71) { + return false; + } + /* "... and followed by an invalid sentinel instruction movec %sp,0." = */ + test =3D translator_ldl(s->env, &s->base, s->pc); + if (test !=3D 0x4e7bf000) { + return false; + } + + /* Consume the sentinel. */ + s->pc +=3D 4; + return true; +} +#endif /* !CONFIG_USER_ONLY */ + DISAS_INSN(scc) { DisasCompare c; @@ -4465,8 +4498,12 @@ DISAS_INSN(halt) gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE); return; } - - gen_exception(s, s->pc, EXCP_HALT_INSN); + if (semihosting_test(s)) { + gen_exception(s, s->pc, EXCP_SEMIHOSTING); + return; + } + tcg_gen_movi_i32(cpu_halted, 1); + gen_exception(s, s->pc, EXCP_HLT); } =20 DISAS_INSN(stop) --=20 2.34.1 From nobody Sat May 18 20:37:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1713999147; cv=none; d=zohomail.com; s=zohoarc; b=FZCNFd4qaVEBrVrgpjQjt3LNAjommsYQnbSbjK9ghMyh/lBozao1gWAW6NAvXBoW5ILn4+7BKVkn2IiJI4rkni7zBQr2voNdXPrh6KyjcQDg8mIEad/aRr8rmBeRMUXAx83pwNDPCSeXKjqYW/Ram1jG2NJHw5xbW0Zh9+HK9jc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713999147; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=G1KuH29eWKziwjTP2PdMM65i8n1Oaouq5HMuEevb+aM=; b=E0bhFRkMaMzyX1NSXxICFWS521Q+/kZsM5PMzagrf0NgmczlUmC7QKEgAbJiKM1f8TvAdYTmD0T5oodqkww/X1cYXDfLTUS6qGRxA4F8NJS/I/Vye4AK0RvVNso3IZYX/zB4QAAEurbGClvJhbIqFX5eGk+xeNBtIhKIDCBtTp8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713999147345152.59288615137552; Wed, 24 Apr 2024 15:52:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzlSk-00070m-2C; Wed, 24 Apr 2024 18:51:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzlSj-0006ym-4S for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:37 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzlSh-0006hO-K9 for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:51:36 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6f043f9e6d7so447750b3a.3 for ; Wed, 24 Apr 2024 15:51:35 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id it12-20020a056a00458c00b006ead792b6f2sm11960864pfb.1.2024.04.24.15.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 15:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999094; x=1714603894; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=G1KuH29eWKziwjTP2PdMM65i8n1Oaouq5HMuEevb+aM=; b=Xv3f/LPjN1GU3fW0+zrMz3qZ4OtqiYKtMU2D7gVofRX6fb/oDDyMyOWRQAOAQua4On A+H1glALATjfCPHIIW0H4fkOowie/yfHmnZ+bDjvXDMnuhdUT7s2ahxIZdcQFq2FQgOR LFdLGAW7YKP4vBPIm0hAd5Is5I5ifDSJwimHmfI3izEuOReAhYaNtys4dRmgxXX/jYTO ujZoDswmUKpG7ZI+Ye2cCU3GyAsr+tm6ulQX0bXJi8mxwGXjCabnaDenf7Aq5AnEGsCC e8VftJYdFtdZ7oukl29jaMHxT3VfyDY7rAPlImz7Mm6qVfox4u7wxqajJruLbiqr7LHb Ps4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999094; x=1714603894; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G1KuH29eWKziwjTP2PdMM65i8n1Oaouq5HMuEevb+aM=; b=Ip3b5h8H8V35KcG/fuHvcgb4CMH78iNa3+wpP3idd0BHGu2LTj+zuKVHKJ1wVHbnLJ fImWQMTSThb017JW/OghLzgNzpTxEBj/kfkk6HLi3eUWGdZzTeXJVQhN5fYdWMClDDW+ hvAlda7hmtaFTsxis5lyGDbGmJt/ByetVQXlHZ1yIoJDvWdHybE6PWOx7LxSzUJmGbwt lapi4ZSbVsL1I8L6C30fe0IjiMVVPqb+cdY8Ifaa17BYicLT99c8ToUP6iGUzPpWGh8c jezRxQOJMA9QBoXlhAhy3+eR2xtSeU3PCMvR6LYcoYcCnz46tNl8Z54B3hJ8j1kJlfs0 drvA== X-Gm-Message-State: AOJu0YxaJE54pg5mLCDjSA8zffE6dxOCtzcU8uwp+KwN4AmhDQW2P25G XcGiM1m6m3n0hpda7aySIzljywS6alFY31tVp5jwHuxPJV2WdQ+Oa8xDIqTVoYciyivqUkvSw7q S X-Google-Smtp-Source: AGHT+IEkVSn7F/keH1gg+6OUG59K7Aho0Tg7877FgFWd3CZqxAYqP+8ZxthE3JqyRMDWGLjusLtVYQ== X-Received: by 2002:a05:6a20:3d88:b0:1aa:340e:237e with SMTP id s8-20020a056a203d8800b001aa340e237emr4626663pzi.59.1713999094263; Wed, 24 Apr 2024 15:51:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Keith Packard Subject: [PULL 9/9] target/m68k: Support semihosting on non-ColdFire targets Date: Wed, 24 Apr 2024 15:51:23 -0700 Message-Id: <20240424225123.929152-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424225123.929152-1-richard.henderson@linaro.org> References: <20240424225123.929152-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1713999148629100005 Content-Type: text/plain; charset="utf-8" From: Keith Packard According to the m68k semihosting spec: "The instruction used to trigger a semihosting request depends on the m68k processor variant. On ColdFire, "halt" is used; on other processors (which don't implement "halt"), "bkpt #0" may be used." Add support for non-CodeFire processors by matching BKPT #0 instructions. Signed-off-by: Keith Packard [rth: Use semihosting_test()] Signed-off-by: Richard Henderson --- target/m68k/translate.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 647bd9d9be..169927552a 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -2646,6 +2646,11 @@ DISAS_INSN(bkpt) #if defined(CONFIG_USER_ONLY) gen_exception(s, s->base.pc_next, EXCP_DEBUG); #else + /* BKPT #0 is the alternate semihosting instruction. */ + if ((insn & 7) =3D=3D 0 && semihosting_test(s)) { + gen_exception(s, s->pc, EXCP_SEMIHOSTING); + return; + } gen_exception(s, s->base.pc_next, EXCP_ILLEGAL); #endif } --=20 2.34.1