From patchwork Thu May 26 19:00:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 576245 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp849860mab; Thu, 26 May 2022 12:05:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7IlsPLsgQKKfHocIxHkfkuXJ5CIezpK7F4J4BeyJSexsbru6WKJipdpmDc6jvSDOe77fl X-Received: by 2002:a05:620a:166e:b0:6a5:c6b5:7823 with SMTP id d14-20020a05620a166e00b006a5c6b57823mr1807842qko.12.1653591932522; Thu, 26 May 2022 12:05:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653591932; cv=none; d=google.com; s=arc-20160816; b=eESRYdxLcxWQLqMc/GZbjF0d6tO++oxe/+WcDh8HVNlnGdNaYWth1ivJu6mpIBON7c 2eswD2SdPR0Pb05FXG5GNHzi4Nvt4CB65Ji5EfKfacwnMmHCEmXgyjjdN3oKSn/IgeQp UaJqBdBpBnXv3Y968ZZxSBWpnvn0SdJf80nRvwtrDkbwEOoMOHHP8MFT05lfeRkuX76J GeaumQPyszVHrRO/j42fWTyOmQDSTAxQgr0jMHxfTtPPsCA5USDI6BfPlXRPc1Y61r5q 2LliVFDayOGWUF3sAMBmR2zzzm4miats4E0vXciUBm3KFLv5gE+Jq876gk83Ac9xCuFD PuZA== 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=BUEk1h6kvEkh1F8d7ZRJI5ayCUpStlTkzTI4Km+ysPY=; b=Fj4AcFxEDxaxWWZKuntvPZlIof0ECwtkh2ZARY0AHUYGeqt9yAkbTK4v4Ouy3fbMbp /m7HtPBdsWLo0mF1Bs3WuGYSEstImwSaurzH8F18AxlJU7Wfd5FxpRucrM36smowbIvB sFjjzXYRF6a4q4WEfVIiSP0vMEkpFSA4TxKNO8AUa20BChCJ2yaxe66Uf0Hi4DCBaeqM q7b8ruQuz/YarwMrDMFzX/NwILnpDl+nG/HgWkeROMOLj5W5GShM8u2wwBsV0C+1kBtJ e40pAfyEWOY/Nnf3rnnRTr9XgC2HpW+u3hS3oJaRhcaaa1vSd2oEPGK41Ts4hpZ20ADy u+7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j138BoNJ; 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 x3-20020a05622a000300b002f36fe23dd3si1461975qtw.15.2022.05.26.12.05.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 May 2022 12:05:32 -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=j138BoNJ; 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]:40712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nuInc-0005Qc-20 for patch@linaro.org; Thu, 26 May 2022 15:05:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuIjG-0002XN-Qd for qemu-devel@nongnu.org; Thu, 26 May 2022 15:01:02 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:43996) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nuIjE-0008OL-E9 for qemu-devel@nongnu.org; Thu, 26 May 2022 15:01:02 -0400 Received: by mail-wm1-x329.google.com with SMTP id 67-20020a1c1946000000b00397382b44f4so1566910wmz.2 for ; Thu, 26 May 2022 12:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BUEk1h6kvEkh1F8d7ZRJI5ayCUpStlTkzTI4Km+ysPY=; b=j138BoNJEpPMFg+yxmrZKjxNU+3H/UlaE4rkagZC+4J0RY5acQTk+jDNwPrniQuPNe cjR2ZtDvIEBqC9DzsW+0swQ8CO8YCg+XVvaevIXlRs/+2aOY28kisnD3//aMnje/OQ3D qfmClcNqrrdS4XR+OLOQj4oC3aJza13H+HKdJCu19k+r7osSXlPy32EAso4iMB0pRamM fkgpxwEq3an6clPMICwVyFyyzjWT/x8WDEIFD6MHvejXwJmML+D6m1cpWN3t/vRebJIi SMksV3Mqnvo0RnM6JTQx1aLkP3+T1i0c0cMma5/HKB45DOl5YaYPVHBefs+zFPKYQOmR k3mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BUEk1h6kvEkh1F8d7ZRJI5ayCUpStlTkzTI4Km+ysPY=; b=v3Cb+ve5U+QR2eRAmdT8IlUwQBs5+lbYZ+SQQsqxrm8b88KFJdVOUcHdsuonWXbirL c8HdcfilmRpkq8YQavSW6Gsa7sO/GYwlJmP8lydhG8fgd1PC1g9+kdyvhJCKViZsyeDO mFnoggOgmdtlL3qW9LvpuafavAHBajeo9eaw2Gcg/S1YcIKBQaLU+UrcPjahMxhFWg0j TXhwbI/QhxZfTliZPkhxjWzvwnbCEx63B60Vvra5rM7AVTls33dgjD/KbJgup/XFD7vw xqyESSrZPuAR28yzTujNeWvBQK3hy+fWzCTjtsOOtIR4bvn/B66gj0fNXskRDaptVGDg Fe7A== X-Gm-Message-State: AOAM531Jwa5t8OwcH9SwD8VbP4nafxNmD6BOIA+tlQU8c8r0x0yP445W uJA+nO9ZnNBGBHgbzJ38ewkoR3NupWNEtA== X-Received: by 2002:a7b:c3c2:0:b0:394:9229:3b40 with SMTP id t2-20020a7bc3c2000000b0039492293b40mr3580844wmj.195.1653591656891; Thu, 26 May 2022 12:00:56 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h10-20020a1ccc0a000000b0039763d41a48sm2507476wmb.25.2022.05.26.12.00.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 12:00:56 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Liviu Ionescu Subject: [PATCH 1/2] gdbstub: Don't use GDB syscalls if no GDB is attached Date: Thu, 26 May 2022 20:00:52 +0100 Message-Id: <20220526190053.521505-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220526190053.521505-1-peter.maydell@linaro.org> References: <20220526190053.521505-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.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, T_SCC_BODY_TEXT_LINE=-0.01 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" In two places in gdbstub.c we look at gdbserver_state.init to decide whether we're going to do a semihosting syscall via the gdb remote protocol: * when setting up, if the user didn't explicitly select either native semihosting or gdb semihosting, we autoselect, with the intended behaviour "use gdb if gdb is connected" * when the semihosting layer attempts to do a syscall via gdb, we silently ignore it if the gdbstub wasn't actually set up However, if the user's commandline sets up the gdbstub but tells QEMU to start rather than waiting for a GDB to connect (eg using '-s' but not '-S'), then we will have gdbserver_state.init true but no actual connection; an attempt to use gdb syscalls will then crash because we try to use gdbserver_state.c_cpu when it hasn't been set up: #0 0x00007ffff6803ba8 in qemu_cpu_kick (cpu=0x0) at ../../softmmu/cpus.c:457 #1 0x00007ffff6c03913 in gdb_do_syscallv (cb=0x7ffff6c19944 , fmt=0x7ffff7573b7e "", va=0x7ffff56294c0) at ../../gdbstub.c:2946 #2 0x00007ffff6c19c3a in common_semi_gdb_syscall (cs=0x7ffff83fe060, cb=0x7ffff6c19944 , fmt=0x7ffff7573b75 "isatty,%x") at ../../semihosting/arm-compat-semi.c:494 #3 0x00007ffff6c1a064 in gdb_isattyfn (cs=0x7ffff83fe060, gf=0x7ffff86a3690) at ../../semihosting/arm-compat-semi.c:636 #4 0x00007ffff6c1b20f in do_common_semihosting (cs=0x7ffff83fe060) at ../../semihosting/arm-compat-semi.c:967 #5 0x00007ffff693a037 in handle_semihosting (cs=0x7ffff83fe060) at ../../target/arm/helper.c:10316 You can probably also get into this state via some odd corner cases involving connecting a GDB and then telling it to detach from all the vCPUs. Abstract out the test into a new gdb_attached() function which returns true only if there's actually a GDB connected to the debug stub and attached to at least one vCPU. Reported-by: Liviu Ionescu Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Luc Michel --- Silently doing nothing in gdb_do_syscallv(), never calling the callback function, is kind of dodgy. But it's what the code is doing already, and besides it's not clear what we should do if the user specifically says "semihosting calls via the gdb stub" and then doesn't connect gdb... --- gdbstub.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index a3ff8702cef..88a34c8f522 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -443,6 +443,15 @@ static int get_char(void) } #endif +/* + * Return true if there is a GDB currently connected to the stub + * and attached to a CPU + */ +static bool gdb_attached(void) +{ + return gdbserver_state.init && gdbserver_state.c_cpu; +} + static enum { GDB_SYS_UNKNOWN, GDB_SYS_ENABLED, @@ -464,8 +473,7 @@ int use_gdb_syscalls(void) /* -semihosting-config target=auto */ /* On the first call check if gdb is connected and remember. */ if (gdb_syscall_mode == GDB_SYS_UNKNOWN) { - gdb_syscall_mode = gdbserver_state.init ? - GDB_SYS_ENABLED : GDB_SYS_DISABLED; + gdb_syscall_mode = gdb_attached() ? GDB_SYS_ENABLED : GDB_SYS_DISABLED; } return gdb_syscall_mode == GDB_SYS_ENABLED; } @@ -2886,7 +2894,7 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va) target_ulong addr; uint64_t i64; - if (!gdbserver_state.init) { + if (!gdb_attached()) { return; } From patchwork Thu May 26 19:00:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 576244 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp847298mab; Thu, 26 May 2022 12:02:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEBM2AIgDVj9zGDTZwLk1db4ISX19nLRCTS+aj/4qvfw7kK8XP2df6GDRMmeduZ/323alp X-Received: by 2002:a05:622a:174b:b0:2fb:411:e446 with SMTP id l11-20020a05622a174b00b002fb0411e446mr7534405qtk.91.1653591759915; Thu, 26 May 2022 12:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653591759; cv=none; d=google.com; s=arc-20160816; b=AfwSBcodRxHexrjDKg20ol4f0p6zFrk/+rNmp68Z3JNIDQsgtOSe2Kn39yu7iN7lbh P4hRL1aTRLQ8j9qIQ7fuGpIrg3Te6m2gkIjwqcxs/S1zHtCGynHU4RoHYTk4bfXLALGa 0ARQVvnIV3u4xzdXB5c7ZMMhiunTDnP7EwXk1fYrlgfGNeKekOt/Hle9petHkYJ4rTVc GTk/s80P7vKPR4o8zjYH7YfYrZc83pb83gyOhJTPo+fYJniMov8zQ0BqzrzSpZM94crp OiR/3ap31RPildyNWLv7fxUXWFBkJdyKpgdD7CHo2NjM4eaU0PNtWOHCRm5HkcZIIEvp IjBA== 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=VdWpJhCktka5KOcldwrFhUo24hWqH7N7zrJHqQkbnLA=; b=QYdq66mjp5S7VX/lRf8iFlqEgTDBQl4ZILUAwmqc8+I+USRyUL32Tr3Hnjr4wxDE3S Tp8z3gfa7n8xVTJBDjOv4XqJtECat/kyZpmNBxlkn+LK3wpIY0qjidYuyWFGqjNpIn9j xsegUTK2Gdek3hKK1HCcxcO1Do8fyHeQpuIA/adlOJgvdy4Ig3vbLEBIFDP5v5O+q2he 5N3aPIpJbviPErk8GiMSvvqIHZFMPCRrpGsav1UKA9v//VxugKLulmgTrjfYAIHJUukQ nCxvPuLtKIbHSzWEw2qZdBdn5jWa+03VDfBhPcUTtzcDflzdJbQQq/fDVG5mFPfS55ES YZ1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z8mE8TN9; 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 g8-20020a0562141cc800b00461c4084ab8si1276194qvd.554.2022.05.26.12.02.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 May 2022 12:02:39 -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=Z8mE8TN9; 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]:36684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nuIkp-0002cB-Gj for patch@linaro.org; Thu, 26 May 2022 15:02:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuIjS-0002bL-2Q for qemu-devel@nongnu.org; Thu, 26 May 2022 15:01:14 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:53861) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nuIjD-0008Od-9c for qemu-devel@nongnu.org; Thu, 26 May 2022 15:01:13 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 7so341800wmz.3 for ; Thu, 26 May 2022 12:00:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VdWpJhCktka5KOcldwrFhUo24hWqH7N7zrJHqQkbnLA=; b=Z8mE8TN9ydfSmtsUb7prJzC9RCS3sOIVBLFN1wrCeHOceU8LtdgpiQAbldAS5KUgrl SeOyOBbUCycqwXKQHoD5lN0R4fAw5hCLjlbbi7k5PCdWIN3aYAysfq8+XChGReUi6+86 OmZ89gSilGbpmYwOlAVOCbHbmk+aNpIFGRWdAeaI6BsnkmSIQQSYa2hS+i6nP1PhlDXp T2wKQkkYTInfeLQTO6PL0wGoWI7VpWrIRgb6QlH89b7N0X0ssSDsaSdTarRbkcoYR0Ig V1nxSY2uMRfnUSsOJx7vPoVF19YPImom5cBrCyPSigqoWqmtFbaKJgrKvPLeyG4dVO56 QKdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VdWpJhCktka5KOcldwrFhUo24hWqH7N7zrJHqQkbnLA=; b=696wyssc5HAfEqU8AG0xDws02GoSDdm8OIQDOcz4Y6KogN0VEAA/74To8hKnkFoVT9 /g2wAKDvw1QrNpBZX1NJIWOJGBD7bYSnF9bUIhGLFfrt00mkRaVsTCgD5Mkiib900xg9 ALkrEym/VrQkhxBV8/Y9TqLwQgV+eMYCkpeBOtt46BOzGwmG2MfgVt8KbVOualzJAvxL LCQlZry431MyLAn1p6mMm0LnFtt7HGZO5SNDm1jtGl6YAFjquw6EdrHU6r81Kr1PlFF2 RrxjcPtltHZxT+aiFQxpCn9JKy1hyHCcZvoshPSaKHQHtIr1Vt3Z0k3IjT2Aw9FHUDa0 RqpA== X-Gm-Message-State: AOAM530tw7i9Gst2Co+X3RNYABVHe2FfkYKJbPUkCz7gB6NIqpPICO9Q H/A8zzq8xX5Mu+KUpmHoXP/NCwXBeevJEA== X-Received: by 2002:a05:600c:3492:b0:397:eea:5a13 with SMTP id a18-20020a05600c349200b003970eea5a13mr3617256wmq.108.1653591657862; Thu, 26 May 2022 12:00:57 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h10-20020a1ccc0a000000b0039763d41a48sm2507476wmb.25.2022.05.26.12.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 12:00:57 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Liviu Ionescu Subject: [PATCH 2/2] semihosting/config: Merge --semihosting-config option groups Date: Thu, 26 May 2022 20:00:53 +0100 Message-Id: <20220526190053.521505-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220526190053.521505-1-peter.maydell@linaro.org> References: <20220526190053.521505-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" Currently we mishandle the --semihosting-config option if the user specifies it on the command line more than once. For example with: --semihosting-config target=gdb --semihosting-config arg=foo,arg=bar the function qemu_semihosting_config_options() is called twice, once for each argument. But that function expects to be called only once, and it always unconditionally sets the semihosting.enabled, semihost_chardev and semihosting.target variables. This means that if any of those options were set anywhere except the last --semihosting-config option on the command line, those settings are ignored. In the example above, 'target=gdb' in the first option is overridden by an implied default 'target=auto' in the second. The QemuOptsList machinery has a flag for handling this kind of "option group is setting global state": by setting .merge_lists = true; we make the machinery merge all the --semihosting-config arguments the user passes into a single set of options and call our qemu_semihosting_config_options() just once. Signed-off-by: Peter Maydell Reviewed-by: Luc Michel --- semihosting/config.c | 1 + 1 file changed, 1 insertion(+) diff --git a/semihosting/config.c b/semihosting/config.c index 50d82108e6e..3afacf54ab2 100644 --- a/semihosting/config.c +++ b/semihosting/config.c @@ -27,6 +27,7 @@ QemuOptsList qemu_semihosting_config_opts = { .name = "semihosting-config", + .merge_lists = true, .implied_opt_name = "enable", .head = QTAILQ_HEAD_INITIALIZER(qemu_semihosting_config_opts.head), .desc = {