From patchwork Wed Apr 24 22:51:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791532 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1091613wrq; Wed, 24 Apr 2024 15:52:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW3BPpnfLAN44pg5oZPMIswGeI/p/66BamtendD7bGUfdTM+3zXJ8XrbA6RY9llPjDcE6CtQ/ydhayPCPXhJcbb X-Google-Smtp-Source: AGHT+IGV8JIJlic9xvllyfn6l0rI4rDn8L9DKjXjegRHfBVmzQU4r8rXgfudc/for+r6DHV41LD+ X-Received: by 2002:a05:6122:1784:b0:4d8:79c1:2a21 with SMTP id o4-20020a056122178400b004d879c12a21mr4776047vkf.7.1713999129342; Wed, 24 Apr 2024 15:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999129; cv=none; d=google.com; s=arc-20160816; b=03BrJJ7C1WvGn38e9Ib/r8kdPAQk5c4AgcSsGfFQNBzxoPVan20lZpVZCoyYP9G3bX NRsjlqWyCptT2zTgx/q43X1QPTv0Fs3vNUObeUYceX5ipMSGkKUjmMuUUBsE4UvMvANA 77eKZZvsd9leBGmwTh2mRnuOYHSsD1tJl/HBqTOaFN7dJVjoCiic/AzHgCDRgj806dOk ZGRQW0c0NLLObzJvENqHetFiVreZcPO/GQtZ9izrHioYUebHY1ERveqP6fAdM6TTvqXQ SMq1tVo5pYfPZJPyhB97bxOAHIz8F0gTPX+wAb5JdfMv4ZAB4PfpvIiop/xMFhGbJfH3 uaAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PIVpHaDvexJpR4v3VPoHT+wrjfi6nDMX3Dvh/TsygHY=; fh=o2XzhdKG+B45MJCghEfnYoypmHvLX2hd4SL6yXeiyXI=; b=Cy7e10OFZN9Brz8So1SVDa2nwlncTqierELwGsvaa8adIoKHRvYJU4J7l5iehQzQGX /F4NKltHjBm6MvV6tUEFMW0X1X81wVgxLA8L36AUj8Fo/cmEDyEUmK2KSqYMz/mhntLp gPPtoJkS5anmcwIoTNQ6UvVrwh5PJmlP23NDJafYFL5jnc1xOihYopLHo3JKwk9eU8fX jr2K/O2MnmPKhhQiZKYyV4BiVS3ZPkXRZtS3IBlcpAdo9NENhGMmh0TzTbxWCReF+eKX R+/yaqoxzHUsYLMHwIOViMJ+2uVJkjC00TPDzVdC8DcptCroplmyG9Ohcsjt/bhhuSmO FSAw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="r7kdj/pF"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v11-20020a05620a0f0b00b0078f0ff5b917si17773918qkl.307.2024.04.24.15.52.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 15:52:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="r7kdj/pF"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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_option('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_usage')) 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').allowed()) @@ -4277,6 +4278,9 @@ if config_all_accel.has_key('CONFIG_TCG') endif summary_info += {'TCG plugins': get_option('plugins')} summary_info += {'TCG debug enabled': get_option('debug_tcg')} + if have_linux_user or have_bsd_user + summary_info += {'syscall buffer debugging support': get_option('debug_remap')} + endif endif summary_info += {'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" -#undef DEBUG_REMAP - #include "exec/user/abitypes.h" 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 = g_malloc(len); @@ -461,7 +459,7 @@ static inline void unlock_user(void *host_ptr, abi_ulong guest_addr, long len) { -#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" -#undef DEBUG_REMAP - #include "exec/user/abitypes.h" #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 = 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 len, bool copy) return NULL; } host_addr = g2h_untagged(guest_addr); -#ifdef DEBUG_REMAP +#ifdef CONFIG_DEBUG_REMAP if (copy) { host_addr = g_memdup(host_addr, len); } else { @@ -24,7 +24,7 @@ void *lock_user(int type, abi_ulong guest_addr, ssize_t len, bool copy) return host_addr; } -#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 support' 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=false ;; --enable-debug-mutex) printf "%s" -Ddebug_mutex=true ;; --disable-debug-mutex) printf "%s" -Ddebug_mutex=false ;; + --enable-debug-remap) printf "%s" -Ddebug_remap=true ;; + --disable-debug-remap) printf "%s" -Ddebug_remap=false ;; --enable-debug-stack-usage) printf "%s" -Ddebug_stack_usage=true ;; --disable-debug-stack-usage) printf "%s" -Ddebug_stack_usage=false ;; --enable-debug-tcg) printf "%s" -Ddebug_tcg=true ;; From patchwork Wed Apr 24 22:51:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791539 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1091890wrq; Wed, 24 Apr 2024 15:53:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW8rrvdTNVlw7n5jcXmJC4L3HQ1cOzS0ArgDS+6bRPhtTtrWJCyDFRCdpFkyLDufD3Wq+62NeLpP5Yb9Rc6f66P X-Google-Smtp-Source: AGHT+IGejCxZ4mIrR6LHQKhHFzXcuEFNqEoXE9IWuRnGsuLLsQlK3t68G81zOTLSmjktG1omyaCp X-Received: by 2002:a05:6214:bd3:b0:6a0:5626:122c with SMTP id ff19-20020a0562140bd300b006a05626122cmr3825355qvb.58.1713999179877; Wed, 24 Apr 2024 15:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999179; cv=none; d=google.com; s=arc-20160816; b=KfQqCM4ewu665hd2A0dR1bKUpYOBrFfUgOB+7lTJYRxk6vq5E6HEJvE5OamQ41N3xr UrHYC2GQ/AwXvVExohgCMiqZldVfgDGSlP/3Fyi6AmurXqurAIu4TtQgMyOTh/ks+msv rXL+br3oU3BTb71iCSa1Uro5DJBzjphlpLrm4t7dtMs4yckX/OU7Eqv64QBjUCPWWOsO nnx5Ui64VBPo9myDvplObri8h7+0eedqLBphns0tL3ov8f86yNZ3ne3sxM/34b7j4HwE 1SlF7CVEcehqBoZRyM1kcVkgQVXlJuhVXxTASQXw9ApYiu+K/8TqKU/T5PJ9MJ2NXkVN sGKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eljbs2yNGMGPnWHJwv7NSq5kkRuO1URzZsDZcIZtS6U=; fh=TF63Ze67lDnVlkd8xmxXNff2WGh+3exboZvnQbD94Yg=; b=hgJnSwiKkLoQ8Dtmb/Qz+Qat8PT9HFf/UC6bUzPYE7Z+zO+iUhJu2YhB7xWXkQknck dmH6xRi0o2W/qy0FuziDaRFzTcweSiGcFSRugMmTc1e/6QU3ixhGgGLG32zpvOLFP9kX rIntR6zs/1fy9YoOcQbX3oY2o1l+y0rA+6XRmxIIuo4lLCUxxozUKrCyyjy+VYrKedC/ jWoem3KshnQjav1lGPcB47eXnOLpOFVCe740xDWjsI9sx5pq3rCvbIQ3ezXU3zowieCH Q/oZEB9DJiTYq7kXa3S5GNBeDILNIm//abrg3d0jf/UvTYC2EhCcPWyOFkWBRcTT801r BPxg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=usK6UKzC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id kd2-20020a056214400200b0069925c427e4si15878070qvb.69.2024.04.24.15.52.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 15:52:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=usK6UKzC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 = g_malloc(optlen); - + char *alg_key = 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 = 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: From patchwork Wed Apr 24 22:51:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791538 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1091881wrq; Wed, 24 Apr 2024 15:52:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUWekjylUG3pHHRx013OgglXaZe7oGxVNJ7i1JLImT+NOef4O1ZwZNjuU000Ytii63AgVQe4TZHW6X/HZ0proCc X-Google-Smtp-Source: AGHT+IHkF0fK/ObeQqwN1sBDCSudN3VcM0t48w4TCM4Z3KMppuC0efqnGZDhoDI99kOVajxlnHwr X-Received: by 2002:a05:6358:9704:b0:183:e8d7:6f58 with SMTP id g4-20020a056358970400b00183e8d76f58mr4029247rwb.32.1713999179021; Wed, 24 Apr 2024 15:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999178; cv=none; d=google.com; s=arc-20160816; b=nnflVM77b33uV6OjUWnvhe0Yx+Mw/CJHRtlcxNfHS7kj48jBgew+qw6a16Bx5annap kyeG18j5FmNf+UxJd8K++ZDCRtd2iWf0rBWzXoqoLGQjmlfXsgDRvvHnuk/QFarr63gA lJqczUzWED2ac9Arn0/FA3T7zFulpuc6Upco2dqv1ZYKRShmJndLoRgC3CT0zi4SD15o 1qBD31l9hIjbmHMNRdxb43RReSRyvQgy12gNNZyPuJS604t04P94gBvbJWTo5oN3k7mG b+JV3arGC2qyGzpl/3BDG7hYWbmXWnTNaWQy4XeJLi3eRLXTmcD+6G5gRwYoPd2egQlB /6qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aRT5ReX6FfNpi8sInY8Erna9AcoUcJ+9OuBKDiXG1pU=; fh=TF63Ze67lDnVlkd8xmxXNff2WGh+3exboZvnQbD94Yg=; b=oIPBvXKm4YaWmow0hOpqusPVLOGT2UT0LLmdh2ZMC1UHkppw9gkfWcVtR44t19LHXB 1vfX865LUeuwW71/FXFfuVbrdbp3U2ynTzMuetATQQrGR/WsLnNgLmY+lSFjFnMzxvcj 84gmLouzacsFea5ZfWuaALeSOfosITYEs/ZCNDn+IY/BFhMBs9oTTPH15g3blhIQ3dXd deXGQkw/G562RMs5BLd50oBCIAzZBwRGn+/wqz47Cpl9pyho9tydjVWxGJ0cdeZPWPqZ ywiHnpqo8jpK8VcDG7ccHgNdtCnDqTx5apDM5xP191C+uxnKkbBXNsbOReQUX1skf2AJ uA5w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZYvc565O; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k16-20020a05622a03d000b004377121c1dfsi16002907qtx.382.2024.04.24.15.52.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 15:52:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZYvc565O; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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_ulong pipedes, return get_errno(ret); } -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 = lock_user(VERIFY_READ, target_addr, len, 1); - if (!target_smreqn) - return -TARGET_EFAULT; - mreqn->imr_multiaddr.s_addr = target_smreqn->imr_multiaddr.s_addr; - mreqn->imr_address.s_addr = target_smreqn->imr_address.s_addr; - if (len == sizeof(struct target_ip_mreqn)) - mreqn->imr_ifindex = 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 *addr, 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; 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) != + 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; + } - ip_mreq = (struct ip_mreqn *) alloca(optlen); - target_to_host_ip_mreq(ip_mreq, optval_addr, optlen); - ret = get_errno(setsockopt(sockfd, level, optname, ip_mreq, optlen)); + target_smreqn = lock_user(VERIFY_READ, optval_addr, optlen, 1); + if (!target_smreqn) { + return -TARGET_EFAULT; + } + ip_mreq.imr_multiaddr.s_addr = target_smreqn->imr_multiaddr.s_addr; + ip_mreq.imr_address.s_addr = target_smreqn->imr_address.s_addr; + if (optlen == sizeof(struct target_ip_mreqn)) { + ip_mreq.imr_ifindex = tswapal(target_smreqn->imr_ifindex); + optlen = sizeof(struct ip_mreqn); + } + unlock_user(target_smreqn, optval_addr, 0); + + ret = get_errno(setsockopt(sockfd, level, optname, &ip_mreq, optlen)); break; - + } case IP_BLOCK_SOURCE: case IP_UNBLOCK_SOURCE: case IP_ADD_SOURCE_MEMBERSHIP: From patchwork Wed Apr 24 22:51:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791541 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1091944wrq; Wed, 24 Apr 2024 15:53:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWaHdssRucT5uXIYfNNHgtGVASzmVVJHFCxbwqSxSZdF4sLT5AzdR/XmHGlFuX2TbqonpK62AjpDstRPZPzWh3A X-Google-Smtp-Source: AGHT+IFkLaextGu8rHtjTAKm+df+z4aQWnx0L3cM+rssbxGDm/sDroNI4F8yFs6k1VItjJ5bjn52 X-Received: by 2002:a05:620a:2445:b0:790:888e:4c5a with SMTP id h5-20020a05620a244500b00790888e4c5amr4732597qkn.34.1713999190640; Wed, 24 Apr 2024 15:53:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999190; cv=none; d=google.com; s=arc-20160816; b=TBmFtY5XqNT+kst+6+Xt7K26/KKb8eacdxEatlXxBCLRSC1yeNWTmxvbx50TsjOTLB aNvlX/1BDEbowvkXkF9BztMlO8mmV0aIMqVBKFIZyaAdHZKhaYNzwlSaaj3TF3p5F9WQ lY86AoyFCtodPN9MnS1BDvl/b8NpIEB3T+3IIRxbGIGyuBkooPCtCoMrqsig9sYQCXSA Hofv1qkMzMSJPVb/0QTlgfC+VU44OOjrVJ3t57mfjbQ/fTurXk+r7waMNnq+8wrV8jdt xGFHSrML1dT6vHaQ5fgUniSs0Y0dhqdlKbLPXco3A7H6Sj/6bQwr3uJsD8kaUd6Z/pkB Yxeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JI74xSWz9fuppvIeUIbROGR0F/ne9t6G9LvnZBioEes=; fh=TF63Ze67lDnVlkd8xmxXNff2WGh+3exboZvnQbD94Yg=; b=lxgjCZC5khpdQq0L6Q3xPMVt+RyoSk2fH5fH9sblUFj6Uz5q35yR1yvGtGmn3Lz8Sk p+EDo/cPMZaWm7Y++VyOzCy/uztJ9Feh703sEyyzOsBe6KX6Uug+ng5bYt082qcnEgJ6 O94HTAdOiefYlJcQu9E9ZWYtPbtPSVy0GJZi32ivJ88Oy0dyt37bgvfhnt7NwnSM+Zmh x3Sroe1uCfEv/azKiMs2oQGCuiEUt0yBO1M+Mc9dJkHg3QCXcHiF/NQD2WXAvfqXEnCz wzPzPy5eTTYlbWqM/EtDPf980NTvnpdXz46KPSBGbulMMf65zmJ0oItXhKQerXK09cYc hTuw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vFFYISOW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c12-20020a37e10c000000b0078ee5516fa0si13097620qkm.776.2024.04.24.15.53.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 15:53:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vFFYISOW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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; 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 != sizeof (struct target_ip_mreq_source)) return -TARGET_EINVAL; @@ -2133,7 +2135,7 @@ static abi_long do_setsockopt(int sockfd, int level, int optname, ret = get_errno(setsockopt(sockfd, level, optname, ip_mreq_source, optlen)); unlock_user (ip_mreq_source, optval_addr, 0); break; - + } default: goto unimplemented; } From patchwork Wed Apr 24 22:51:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791533 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1091626wrq; Wed, 24 Apr 2024 15:52:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUsQp1XxDHBF/b5arahHD2T1vOGrrlLCF9JurvrYvDNUvA40AUq5IYgHjNklvY4IpZ+mKWUtyJcpNd8NzR286Xe X-Google-Smtp-Source: AGHT+IF3TIC6GCGVi2EuTu1d1O0TkLSBP340CSC1l1icyIwwNW0jcGCu1ZnND6ZpxUEUraZ4k3xs X-Received: by 2002:a25:84c9:0:b0:dbd:8f9:a71 with SMTP id x9-20020a2584c9000000b00dbd08f90a71mr4203133ybm.28.1713999131843; Wed, 24 Apr 2024 15:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999131; cv=none; d=google.com; s=arc-20160816; b=kQVoXOc+vq4QUQdne+CS/mba1sXvxjcS76sMuTjtUFS5YGAz6B/PC45nuUSBG8r5LS mQ+ZmrLcGkX4xiXg2Zr5rMIAUBv6O5IcS2WRuoEpioext24vMmXDR/1KLi4762ND3dFx yVbB6rx6B23r4XpOuQvLGpqf/iwbi+bYczfyBbsJKVxJO0kQ/IEru4dF94UVRdyF9cG9 g72TvC5XGoYxiuWh2WckNrb3T8aRseivV084xmvmrVo5QADhCfnKwzhUOpz1d6OcRKlD xzIGHb1pWp5Sfs6hDRYHWhcoYJhxxTXh8pki9lJ8on1dzx8Ik34kl7LfwY63loDqj4ds fkww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/Qew14nZN1wX0iqwNUmvetvShYAajmyZbQ1f420VzBg=; fh=stWDERV0X+fGADjSDb+zJwQg8mFVbbU8pKGYcikE+Mc=; b=Y3JjGchzt5+cthktwC69jBXg7zRuxd5lUQy48mpn5tUM7NCaOFpwdDkmIi3uDL5iAd gFlOZdv2iXQm3gzV5SwESLf4vnMGxuI6lHjlpCGaWgTKfdCNpr0f2d99RlEkO1V85542 NjUWSXuqH93nEUK/L+wIC3uNa9SDEXHhmHBmilmLBlQjwAB4qIjfvmPLKmrG0wiRpXCD kLL9+XUf/sUyCcwspoIx/tDkFAXoBHFxs0itHNwAHdZ4NE9qCofETBRGyJvmdH64L1/R kUu2/S3P6bmaZP/vNlX9zEraGc9MlKdChXFlfucS/97LYPfwtsXB3uq8DzTf4v0fNGED RqxA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nl1fYlMg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m12-20020ad45dcc000000b006a041891814si16496664qvh.587.2024.04.24.15.52.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 15:52:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nl1fYlMg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Michael Tokarev , =?utf-8?q?Philippe_Mathieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é 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; - optname = SO_RCVTIMEO; - -set_timeout: if (optlen != sizeof(struct target_timeval)) { return -TARGET_EINVAL; } @@ -2315,13 +2313,12 @@ set_timeout: return -TARGET_EFAULT; } - ret = get_errno(setsockopt(sockfd, SOL_SOCKET, optname, + ret = get_errno(setsockopt(sockfd, SOL_SOCKET, + optname == TARGET_SO_RCVTIMEO ? + SO_RCVTIMEO : SO_SNDTIMEO, &tv, sizeof(tv))); return ret; } - case TARGET_SO_SNDTIMEO: - optname = SO_SNDTIMEO; - goto set_timeout; case TARGET_SO_ATTACH_FILTER: { struct target_sock_fprog *tfprog; From patchwork Wed Apr 24 22:51:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791536 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1091788wrq; Wed, 24 Apr 2024 15:52:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVv43jwtZ4Em5LFabnCBmp928gK6IwBXnZw8gw++TSiJ1BPPOtm98Ew2zExwnptkhy7BqC2HUuCIVbPWeaBqN1R X-Google-Smtp-Source: AGHT+IFUnrzzgQzU4m5umHQPsB3G2OKqt2Xtdk/OqO5Nz0CPG+3eDha2WR6IVIeQ0+eEVCnwm3PZ X-Received: by 2002:a05:622a:4b10:b0:437:b830:e498 with SMTP id et16-20020a05622a4b1000b00437b830e498mr4798798qtb.25.1713999160740; Wed, 24 Apr 2024 15:52:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999160; cv=none; d=google.com; s=arc-20160816; b=tExUOyh4wG5MTxDRKLZRzRnMfKtuO3nj+O+pvdMHLd4jP84xMdeyKB6k6J3X7wbPD2 oeUIBXAQsYQLIf7TFh+sH7b63fTQOKdBCx6mV7bUm8xiufzvO6saqYlUiYG59KdqGpNf 38giFZZ8c6z6xovs+RV5ev+nBw6zEi9dihxO5J9CFKbvu1jgAWZmpKICNPb4ZbVaqWVM rvdKfAwDnygh66apjomSOB6LtdX/gWuIZKgkLmwqw2rpGDzgM7oZDwseGAb2tXRqrYW6 +E/JKToJG5SC3aBy+ooc/ZaBEYHm6LrKajMA94F0dCcU0NmWHo4Rnt5iKhve1KyiQUgS rVUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UDr6R2ma44jwvkJI3Qs5id/WJ2z4/lQ44GztsnjZcyw=; fh=u9DhXX/1+w9V/lPughVlk13Er6RrFul+1XrnqwizVQE=; b=H/BzJIM2DNBM18g6iotWVSdSRtM5+c6KS+EaLsBPWf2E6tySGCNF1ONGvxzRM8kJwQ /xtBD2iBYL/wC19cDwnrkqY1M3AHLDMqC7JOi2PPfQX9MlmBkSoh02fS3/hmpVJAD6rb FiAMQTjDQHhiWA8Q+RihpioWm5Zo4Lr6F/QT7lk6zNFhnbVkSARjnaH7aoBssv9/V08l SLyVSlHsW4rmwFsLb1Ege5afBzgqf2dm/zo5eBumNrq2nrf9UCPSSEcNfZvTPJ4KRT+H AMS4dTi9p9/NQHuLaB12AeyeT/objdgU3GOwHdQrFZo2ngn/qvEyOOGvmMeGwp6qnV7d RT6Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M+6bxgx2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g2-20020ac85802000000b0043a18d47571si2836381qtg.15.2024.04.24.15.52.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 15:52:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M+6bxgx2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 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 { #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) /* * 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 */ +STRUCT(fstrim_range, + TYPE_ULONGLONG, /* start */ + TYPE_ULONGLONG, /* len */ + TYPE_ULONGLONG) /* minlen */ + STRUCT(fiemap_extent, TYPE_ULONGLONG, /* fe_logical */ TYPE_ULONGLONG, /* fe_physical */ From patchwork Wed Apr 24 22:51:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791540 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1091940wrq; Wed, 24 Apr 2024 15:53:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU7yBmAhO5AVE7OnYQ+XgeAAZsNC/b2dISh3jpkV/D3zPWySz5nOosM4wnmY2zFo48j0WtOM9InVK3iaqxJk3ME X-Google-Smtp-Source: AGHT+IEvmo6iVxZtYblkqeeBBM7BK41/eeuJc4tfY8RevNvSJgS0nimwebl7/Ufgu/GYGUn3Z/er X-Received: by 2002:ad4:4d4f:0:b0:6a0:947d:e7de with SMTP id m15-20020ad44d4f000000b006a0947de7demr3703797qvm.8.1713999189240; Wed, 24 Apr 2024 15:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999189; cv=none; d=google.com; s=arc-20160816; b=v3I0WwZhrU4+27MbyUzKqM0eysIRYJJcYPTg99aUTraxN49vvf4xqazyyueC8Ygp3Z z+QvxIt5UiAYt/X1hVtWae2yx3vtn95MXahMoomNNetyHVh9nizDbIfvOLH1H8VmZeYa ZGAI6nS4dGb/lFhyDt0oXjZYApTd43jJ7SpdFTW56an4Kvc3bgomu/c4bzqmNaia8SqN LJ6ZsAj+VbDRiHHPLXHzwjXh+6e/AxJlT8upHtNdJ0y0QaWfgKiSRFK4ez3B82PBj81p BQUYUW05AsDORvZtYBPVUxHx1eFFzmIpPgSUH2ZwG3HqPNikod3Mzn3ah3qxYfzm4ab1 4pEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hIaIEQSm9VCOv6FXtjW2b8GU4ZH5b2a473JIJYHIFaQ=; fh=P3j12pZrhCzqOnqZjKPrBC9OQstkED2dDYfAmFoOlTU=; b=gYlfwOMB1nZd0bxROhCoDv1helfiHJ00q+kovZino1YDoTO0qEOLIo3f+ylFsW58gN r+jQDD2So6OrffkKjdefWmn4XS3CMiW4WxMJd/HSSXLtrqAz9y/qXrEd8mE2yhre4tK3 KOWVAXzfzk4q6Rh5zZZQbYsDLouyvWI/xOPOSs0GgMMqZhhKdv2+VejkCk4MMMga9Yrh Ongwfr7jJKDauPVWWomofhQAXxtnycUXV2gRmI0Tpd+4Zk1gYx7zpza7lB+UvkyktR8q TeF+fyHG6ZzxsL1nWXehkktAs178DD0pZ+88/aNmmx1hz/8XOuBYDrKkPMAhrPxZRg5u NzIQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B8pj1X+u; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r4-20020ad45764000000b006a09f4be5ffsi193171qvx.57.2024.04.24.15.53.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 15:53:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B8pj1X+u; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 = 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]); case HOSTED_OPEN: GET_ARG(0); From patchwork Wed Apr 24 22:51:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791534 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1091713wrq; Wed, 24 Apr 2024 15:52:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWmBc5XpgCn8s6wrq6olagVNGnfPO26oU+nEKO4dugMZMboXeEn4UqmLrfR2Axl2ZmYqTydLKXjnW/Bg+QH/4dc X-Google-Smtp-Source: AGHT+IFq5UmB3dKvAOpnOxo07vgD6svOVHHWvCrsEBzPsZOKs7NzPXzyQhy4kaU4Nixca5xSDpDE X-Received: by 2002:a05:620a:28c5:b0:78d:53a1:299a with SMTP id l5-20020a05620a28c500b0078d53a1299amr2135095qkp.12.1713999146438; Wed, 24 Apr 2024 15:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999146; cv=none; d=google.com; s=arc-20160816; b=ILU1IZM+bJjT8hiLGUqFvMLnRrw/EjlQXuvJDQbNv3FeJbe/8D/DBNl5iAIgQs392S 63oAgsR0io1Zp3MjS2IhKSv5Jw4RNfTYCFD9PCEeS9o/zs55q072nswrUjFQJYWQqHM1 eMOUyjRBswyp6WUYTBNxdUBkgZceqwMWtdTXqQEScAADjGSOiUbmRzofJOV3HlaAlDZt uLv2G/oqWnTw7CaTsnT32RHkVEJlrNPnIoMpuuIZab/N/zYm0PgdaWQIXlic+YWdtbtF M1/FM2mEflqFUpZlPv6clL7CVoAlTagPFIY8AqrKR1ik7WFnAnXmqK9VUtWGEWm4h+8R 03vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=N1Fb/iLBacLjG+JYW3VIwBtHrdP9tAIF5ogLnK/WoGA=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=00L46RJRTAdRNfV72L7NWt/qOUfa9HVIzQzVHxUqsEsLY2wgjJHuW3OVq2EH8PedCG IZMxewWu4vYEtrPHY0g8FXOAnyGdUV2yxtYkmPESnTkOJ1JzDAqNyVA5E/qr3rKMvHr5 yrtrStknSa+0T4ZwDIffTK5Fin2IppOWJYchD3AUFcKyBViYdupjnUSvifHAgk4Dsol/ C+4bjcZF7Kk0Xh4BNDJz/1GuUIEspZNntA6qjNk33Rc4LH35izw5X+ZAS0yc9jKq2Zhb GqHPcEF3jknktXZviTrRO7G1j77NV7qc7VxRrqQxNxwbjv4R96fl3KjsivgvtndZ9Sji WGOA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gXL7aYad; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v24-20020ae9e318000000b007906d1b6826si8874187qkf.157.2024.04.24.15.52.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 15:52:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gXL7aYad; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 */ #define EXCP_RTE 0x100 -#define EXCP_HALT_INSN 0x101 +#define EXCP_SEMIHOSTING 0x101 #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) == 0) - && (env->pc & 3) == 0 - && cpu_lduw_code(env, env->pc - 4) == 0x4e71 - && cpu_ldl_code(env, env->pc) == 0x4e7bf000) { - env->pc += 4; - do_m68k_semihosting(env, env->dregs[0]); - return; - } - cs->halted = 1; - cs->exception_index = 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" #define HELPER_H "helper.h" #include "exec/helper-info.c.inc" @@ -1401,6 +1400,40 @@ static void gen_jmp_tb(DisasContext *s, int n, target_ulong dest, s->base.is_jmp = DISAS_NORETURN; } +#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 != 0) { + return false; + } + test = translator_lduw(s->env, &s->base, s->pc - 4); + if (test != 0x4e71) { + return false; + } + /* "... and followed by an invalid sentinel instruction movec %sp,0." */ + test = translator_ldl(s->env, &s->base, s->pc); + if (test != 0x4e7bf000) { + return false; + } + + /* Consume the sentinel. */ + s->pc += 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); } DISAS_INSN(stop) From patchwork Wed Apr 24 22:51:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791535 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1091715wrq; Wed, 24 Apr 2024 15:52:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVY0PB5Tzist1CHigYSn6uvZ+EWy/Qu8hVeXEeJ32sFubnQRIGzOb3gpIoXp1UqIYL1LqOuGWqcL0pMqCtEwCTD X-Google-Smtp-Source: AGHT+IEp6ZcwLqsUck625zGHw3FUU/bvwTlMQLAjq/QaYNs6/cB9gje1PpTRCGUi6c+YV3gobGTK X-Received: by 2002:a05:622a:11c5:b0:439:b6bd:ccb3 with SMTP id n5-20020a05622a11c500b00439b6bdccb3mr3746308qtk.0.1713999146934; Wed, 24 Apr 2024 15:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999146; cv=none; d=google.com; s=arc-20160816; b=kVSKHB4r9zlZ3evZFEpiiNe5Jx/3Zgxdif12dUkPs2m/O+NgtVUmxnoYzby71zyvV4 Dd0fjvriVf4y5WeCxEDhvL1xXx6e86U/nynmqGgLLA99dTgI6IkU2xApuZ52Ggcg7QVP lxEGY8TzZqGvFQA3GlfKWxIbV/RIJgMlRj6FOlzpOIoiabmYcRc3h2jwsdBYMQdeA18k wP4+Jmht1+MVVYQp5GEgJf7ENH9lwbi+z5HqUMhU5cG1wBuUcyEKOIcFcxIayXLEcjw2 Y2q0DpomtoIAbJ3fm6vjtCzsZzFRR/Kh4z1qxoYHZstl+XrqdXsYtVH2RWTVa0AJRRBF hn2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=G1KuH29eWKziwjTP2PdMM65i8n1Oaouq5HMuEevb+aM=; fh=LEzS/2znb383K59gW/mE4txfpskH6W/tMhITWj/DbfA=; b=Z0KpFcHImOGJpr0Y7NFMIApieDYvhCma6FFQ5jwLYn5YYBn3b0sTjwx6HHl8oTx8KM S4jCP7+0Z7nG1Y4yaaXFimRWjXBJf9EA59dAdJTig5il3inOeHeUkjFf3wOzdQBkYZqm 3wmJafh/q+S3nZNZWj//ixzEFVQ+0j7c06OcUKHpiFA0G+Be3hFoaE0LEU3C81LKyBWr rHuzt/PmRrZE7NXrsCzzSNEuVjVpKK/aS7iefb4+wC+qtu8fY8fpJ4rwiTOG3UEClafL HFRt5cMn2Zwo7g+gm0QBBh4evqwU4+5MNaAyZ68tAZTKgKnnqxeEgIyP3+3Pk70yUAj/ COqg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Xv3f/LPj"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fy26-20020a05622a5a1a00b0043a42fc50e2si446465qtb.365.2024.04.24.15.52.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 15:52:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Xv3f/LPj"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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) == 0 && semihosting_test(s)) { + gen_exception(s, s->pc, EXCP_SEMIHOSTING); + return; + } gen_exception(s, s->base.pc_next, EXCP_ILLEGAL); #endif }