From patchwork Tue Mar 18 21:31:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 874427 Delivered-To: patch@linaro.org Received: by 2002:a5d:6a90:0:b0:38f:210b:807b with SMTP id s16csp76349wru; Tue, 18 Mar 2025 14:35:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWFNziXxvTZ03N0gNR1eCHt8YJ+Y6i1M/m6mdV1TtAtM/PYA1mWHw/ZgkzZxAnbuDxOzpvI7A==@linaro.org X-Google-Smtp-Source: AGHT+IF+INPVO9FIyuu22gS2V0mV6mVo+ykyynbA1YMkPRT4LxGt4lqCycEf/7EEjDdrMBJXly6C X-Received: by 2002:a05:620a:4095:b0:7c5:5794:3e66 with SMTP id af79cd13be357-7c5a83d2986mr32585685a.31.1742333743890; Tue, 18 Mar 2025 14:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1742333743; cv=none; d=google.com; s=arc-20240605; b=bGMUh18zOl1lEMohDB6UOSyKF/pVBGV23EmBaEIKXTYETUOIG6tzXsgmv8ebw/2sTg k8ihw1W5vl6t9HVRyC0fxEi8PeQ+b1Elqg4m0eNjnVx7nkKIc+pWtRz+Yheb81vhKDrr KDmYMTVH+ogWu1bDeH8TOHKD0yHJzir/mw7dQzup6QSD6f7mMdOXjsc+Kf0wDcvBCrID y3zay/a1dhSpfRYvSHzhYSc7vKBMOQybFuG29Ot/UgvoxHQMdvLKH+t/q0YnacV411qg pDXbphSosT0gcaZdzX8ToFGTTeDDTY30fH4LAGP9QYaxZgViL4okX5m2FbMrGBOSpaTK 7KjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=ggA+NUCTfLjXVXevEP+BP9AcTpKIsc/HWrtDpZAfGPk=; fh=6c3iePwzSVcIevU/n11cXtkmPbvvYSh1prLosaYzn/o=; b=fvOHWvSG1F6ph7Rq8dpFg6BelpCHhBozpUD3K7NI+5t8XA75ccpfEDJGFjCGrcpUok 88H0f1RaakdA60D8Yn0l44RNo+0uL2oQFsud9fTNi6aL7SbMAklOe1dSuAql8wmxEPLF CsYofa3VbjHt6gAmHD4KCcx3iOZTIZtNjqFzrHPCbx7snbU0ZMjl1AYZN+iz1usHwK3W A11K24BQYPE1Cc8fP/MKSD1dNwOsmqlL5wIJV8YRnDblcdtwxe5e50p/PRSrdOcVP85o NZ4C2l+/MREITh7j0h9EUJGDobil1lWwiUG4tmYU3RWVO4gpCWcenHRNXRWg7tQy26Bf Pwtw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i9+G+Xci; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c573cec3a1si1278062385a.354.2025.03.18.14.35.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Mar 2025 14:35:43 -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=i9+G+Xci; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tueZp-0004OD-Ga; Tue, 18 Mar 2025 17:34:21 -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 1tueY4-0001KP-U9 for qemu-devel@nongnu.org; Tue, 18 Mar 2025 17:32:33 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tueY2-0000nv-TO for qemu-devel@nongnu.org; Tue, 18 Mar 2025 17:32:32 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-2255003f4c6so110623475ad.0 for ; Tue, 18 Mar 2025 14:32:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1742333549; x=1742938349; 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=ggA+NUCTfLjXVXevEP+BP9AcTpKIsc/HWrtDpZAfGPk=; b=i9+G+XcieQMojHKfgz/du8WSsnxTFD17ucyC6jktM60tlnxaSNvN1RoPk2xDzOiXRL 08ojcFeymfTFYCOm0kgk9EbJjOquFzlPzvXTrRPc/YfBFekCkNDqagxYqHg4i1ltBzsI xCyujkYeLK43evv2ek5eaTb8f+ptywFfNR2a1RmQiBtD3kckXrBOjrFDgXMQP0EDaIYA FNUAuZE5A8neE1M9JiNV08rlgIQhCAcuO8eWqqJ9p4xfahf24t6WgEJngt6Ju677YYpE r4HtceIsUnKc9Oataj6w0QaKpwAUwhz2seXcu9wnJf6ahfZDy7YIHSr1FWkTebBnEYrZ 2uiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742333549; x=1742938349; 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=ggA+NUCTfLjXVXevEP+BP9AcTpKIsc/HWrtDpZAfGPk=; b=vIE5Ow/d9WeoeyAkxde1u8SKWbNk42TmDFiSPsVAEtCQlNHVSKJ2xmaFPMng4FprY8 XHlpFTAEqdt155rTtdZc9a3UXEvlvZPUDFRgVLGGQbyCEShDr9POEom8P/aMRXOY6SYh V3rb3u1tZ3K/9rSnCXFgWocB4wHFQORCsSidhaJg1sDS/e4gHdvnY//179yxsQkwah7H 9grCjYPFMGYaiyIMH40RHX0QO82mBTxPvaEjax8enodAtg7gKmWaKglhzPa4wedvHBgg Z1e0IfRur3n1InjnXXEsJyA6LJ+j7nnSVMJ91sRoasAFe235e54PN3KTr3WtnmLZD5wO 9MEQ== X-Gm-Message-State: AOJu0YzYZt4YyrKkWZvXbtBidsfOT+c3WxyCsr0xQcKneLAx8AvSc7L7 MGjj9bfVndFaIQXSoP51S2/7cWGDBWLkEIt8QAWAG6OvjGpo5jXXyXa865YEBfNhvFTi8EDcPjJ D X-Gm-Gg: ASbGncvI1lG2ErdzlB4fUcCESqCIeu+eGqiKl93vDx/GATI+Ax4OhudFk4dpz6ZKJRp 1JkoPFAQs8mXsPzYL6/gYYTLbw0NcKfRZ750hWbqD3wHUDcUTNaZIfKpo3jfofVwVudM185TBUq ucyfGNVoeL19eXD4+PYMegZ67p4HLTJfyCuiAXRN/hkSuo4qAfCjyhmeJfcMR7kHjRawcJZ5Dkw /H3T7Ly5rgqSMbVBplx8w+Y/jCtd+VyKnpOYuH9iQzb0++maHYtuq/t6q6Z0ST/x+cIdb80H9xW l+u51hEMm1y0l89L9y6N1jJ+DL42Gq90PJonmF6MW+gSUJ/G7ZMKs1sIZoccaroOvvGITniwc1U g X-Received: by 2002:a05:6a21:68f:b0:1f3:48d5:7303 with SMTP id adf61e73a8af0-1fbece41f10mr336813637.31.1742333549169; Tue, 18 Mar 2025 14:32:29 -0700 (PDT) Received: from stoup.. (174-21-74-48.tukw.qwest.net. [174.21.74.48]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-af56e9ddf4fsm9473854a12.21.2025.03.18.14.32.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Mar 2025 14:32:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, philmd@linaro.org Subject: [PATCH v2 26/42] semihosting: Move user-only implementation out-of-line Date: Tue, 18 Mar 2025 14:31:51 -0700 Message-ID: <20250318213209.2579218-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250318213209.2579218-1-richard.henderson@linaro.org> References: <20250318213209.2579218-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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 Avoid testing CONFIG_USER_ONLY in semihost.h. The only function that's required is semihosting_enabled. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Philippe Mathieu-Daudé --- include/semihosting/semihost.h | 29 ++--------------------------- semihosting/user.c | 15 +++++++++++++++ semihosting/meson.build | 2 ++ 3 files changed, 19 insertions(+), 27 deletions(-) create mode 100644 semihosting/user.c diff --git a/include/semihosting/semihost.h b/include/semihosting/semihost.h index 97d2a2ba99..b03e637578 100644 --- a/include/semihosting/semihost.h +++ b/include/semihosting/semihost.h @@ -26,32 +26,6 @@ typedef enum SemihostingTarget { SEMIHOSTING_TARGET_GDB } SemihostingTarget; -#ifdef CONFIG_USER_ONLY -static inline bool semihosting_enabled(bool is_user) -{ - return true; -} - -static inline SemihostingTarget semihosting_get_target(void) -{ - return SEMIHOSTING_TARGET_AUTO; -} - -static inline const char *semihosting_get_arg(int i) -{ - return NULL; -} - -static inline int semihosting_get_argc(void) -{ - return 0; -} - -static inline const char *semihosting_get_cmdline(void) -{ - return NULL; -} -#else /* !CONFIG_USER_ONLY */ /** * semihosting_enabled: * @is_user: true if guest code is in usermode (i.e. not privileged) @@ -59,17 +33,18 @@ static inline const char *semihosting_get_cmdline(void) * Return true if guest code is allowed to make semihosting calls. */ bool semihosting_enabled(bool is_user); + SemihostingTarget semihosting_get_target(void); const char *semihosting_get_arg(int i); int semihosting_get_argc(void); const char *semihosting_get_cmdline(void); void semihosting_arg_fallback(const char *file, const char *cmd); + /* for vl.c hooks */ void qemu_semihosting_enable(void); int qemu_semihosting_config_options(const char *optstr); void qemu_semihosting_chardev_init(void); void qemu_semihosting_console_init(Chardev *); -#endif /* CONFIG_USER_ONLY */ void qemu_semihosting_guestfd_init(void); #endif /* SEMIHOST_H */ diff --git a/semihosting/user.c b/semihosting/user.c new file mode 100644 index 0000000000..9473729beb --- /dev/null +++ b/semihosting/user.c @@ -0,0 +1,15 @@ +/* + * Semihosting for user emulation + * + * Copyright (c) 2019 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "semihosting/semihost.h" + +bool semihosting_enabled(bool is_user) +{ + return true; +} diff --git a/semihosting/meson.build b/semihosting/meson.build index 86f5004bed..ab67f87e4f 100644 --- a/semihosting/meson.build +++ b/semihosting/meson.build @@ -15,5 +15,7 @@ system_ss.add(when: ['CONFIG_SEMIHOSTING'], if_true: files( 'stubs-system.c', )) +user_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files('user.c')) + specific_ss.add(when: ['CONFIG_ARM_COMPATIBLE_SEMIHOSTING'], if_true: files('arm-compat-semi.c'))