From patchwork Tue Jun 28 04:53:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 585503 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp451132mab; Mon, 27 Jun 2022 22:51:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vO3JnLYyFrlHIliwY3Xqd5nhUpZsKYKdNG9LhXT603cCkIyqfvayEKwfLW4RP83Mpaxpgv X-Received: by 2002:a05:620a:798:b0:6ae:ec93:e6f0 with SMTP id 24-20020a05620a079800b006aeec93e6f0mr10313433qka.413.1656395503441; Mon, 27 Jun 2022 22:51:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656395503; cv=none; d=google.com; s=arc-20160816; b=SQF4hGZ34S/yyb5VDwq8A9iqUKPAJLgTKDfuy/WNJtFfMg9itrUidULEKIE0Kigg1W 4R61otPftxiu/Cyiy9nK90KghuSlvYKSuJdnupp/5HxfhJTSVxjf41BDpBqjOeDzBeTs XzW9bShCgNK+fwlDTrvHFsQ1VO8YYcmVMgFUH9LQ+kQtnqOVyBnFTLs+v8H+ZQbpTpMW 0ys1tBxA5Q3efCA7U2N8eEB97s+oqcTBM2NYw4WwntyTR2umSHw5TmabMB3hK1yd20xW sQqxge5fBKu3ovq8+glj1VtGgPZcHwjC2IW5jw/NdmeWVr/toacxJsmm4v7mS6BarSx6 ikbg== 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=UtCh1R/o+jWczZ2gQY+9f4Xav0T6t+bxgoxTR2mENvU=; b=n0e08SowxKTEfylHKNZmg8GOP0bOKzMEP4uQ/G0RKCQPuQDnYvUp+kl4DaqvjVk7yq ommtsMLhm8QdheR7nd0Q6YJabEn02ZFdVkGhPJ1Z+APDNLPJCpqCtXtekvg9Xq9ZgWdY +M/R2RE3RIsXzVA+3M+BJOaNmAzw6pifkSKEjnmOFP/Vxzm0Cc/rGXAqD5jFEQ6T6qVW GteUbwPY3GXtTmh9iV38OM2+g8iXlDZQzgLkTZk0sPSd/LcNC03D+IJYdlteuBN78I/m qysSAnIkRE/D0BMv6RkEwdPGaPSN+PGvcAmyetbbqhsKtPVavLlhVHvxIVsFXIIz3eUR QRFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qGMtCKFK; 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 z3-20020a05622a028300b003052f5b3302si7530754qtw.730.2022.06.27.22.51.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Jun 2022 22:51: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=qGMtCKFK; 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]:59878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o648U-0000hQ-US for patch@linaro.org; Tue, 28 Jun 2022 01:51:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o63Ey-0002Ck-Gk for qemu-devel@nongnu.org; Tue, 28 Jun 2022 00:54:21 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:51860) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o63Ew-0008H4-U0 for qemu-devel@nongnu.org; Tue, 28 Jun 2022 00:54:20 -0400 Received: by mail-pj1-x102d.google.com with SMTP id l2so10248114pjf.1 for ; Mon, 27 Jun 2022 21:54:18 -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=UtCh1R/o+jWczZ2gQY+9f4Xav0T6t+bxgoxTR2mENvU=; b=qGMtCKFKQ/U+TbLepNcm1TBMz8/zuUTmR3SAF2lbc1iJTUeLGTXpE2wy4OALtVW6Mx eyhWzWzd1NUH6NpMQ37tPTsQJMXkY2B7nfnNKQoI6P6CZ97Cf3JEX0YxC8c9Mrx2Z0i4 2UvRus1ai+XWCtEl8VDnhgXWundayqjCwWISossbSvscHBKGyyRaMak6osp23xAuLLCG jBOi65PcSeA+u7cptt6PjidNudmzEt04mDvSpJyy6L42dZZJBgebfqHVhSv9jlcwwH7r Hpz5rJAJ/95j7FYqpnLcajOLN3ccAcjJNnfQ2w//wwmDV8I+NoSaA7VM46PNe7S7BoW/ 70aw== 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=UtCh1R/o+jWczZ2gQY+9f4Xav0T6t+bxgoxTR2mENvU=; b=cxo238cMfIOFyUD/M8yl4KmPLEDs4iVWlXnhL61YmL8/jix95FxqPMXBgu9xyEf0j6 3zdRYFVGZjc0fWdrBsSZ6Pgw3Hau9Av51gP2vgqwyx7QUZex45sUwp37gYezUMGwAKES 68QStDInW/uAoCQeTPszrGgST4lrKHn8KjXgrlFXtXZnjnXqHM0QYnfS9UHTuEi4y5Wz VmdlfT7TYxSuYtU+HXe7yPtRpDMEgQHc9DTYAKF3vJZNSrjxGkzOfYMgTAzk9CTw6tc0 CE4Gguvem0nj0DJX9ikWVey/TNs62zHc/U4cb9NFS/VWWrQknjMnAcyuhgaV6EIM9T8A k8jw== X-Gm-Message-State: AJIora/RMNcYx7fwDvdbgMw32/ldSBGi9QOkGxfhxHNojYsk9f4fM78k Db+Pqixo2dRvPSkXgSXwWAdlS4z582CD+w== X-Received: by 2002:a17:90b:2251:b0:1ed:29d2:e013 with SMTP id hk17-20020a17090b225100b001ed29d2e013mr22800287pjb.223.1656392057628; Mon, 27 Jun 2022 21:54:17 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id w8-20020a1709026f0800b00168c523032fsm8073735plk.269.2022.06.27.21.54.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 21:54:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Peter Maydell Subject: [PULL 04/60] semihosting: Move softmmu-uaccess.h functions out of line Date: Tue, 28 Jun 2022 10:23:07 +0530 Message-Id: <20220628045403.508716-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628045403.508716-1-richard.henderson@linaro.org> References: <20220628045403.508716-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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" Rather that static (and not even inline) functions within a header, move the functions to semihosting/uaccess.c. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- include/semihosting/softmmu-uaccess.h | 42 +++------------------- semihosting/uaccess.c | 51 +++++++++++++++++++++++++++ semihosting/meson.build | 1 + 3 files changed, 57 insertions(+), 37 deletions(-) create mode 100644 semihosting/uaccess.c diff --git a/include/semihosting/softmmu-uaccess.h b/include/semihosting/softmmu-uaccess.h index 5246a91570..03300376d3 100644 --- a/include/semihosting/softmmu-uaccess.h +++ b/include/semihosting/softmmu-uaccess.h @@ -42,47 +42,15 @@ #define put_user_ual(arg, p) put_user_u32(arg, p) -static void *softmmu_lock_user(CPUArchState *env, target_ulong addr, - target_ulong len, bool copy) -{ - void *p = malloc(len); - if (p && copy) { - if (cpu_memory_rw_debug(env_cpu(env), addr, p, len, 0)) { - free(p); - p = NULL; - } - } - return p; -} +void *softmmu_lock_user(CPUArchState *env, target_ulong addr, + target_ulong len, bool copy); #define lock_user(type, p, len, copy) softmmu_lock_user(env, p, len, copy) -static char *softmmu_lock_user_string(CPUArchState *env, target_ulong addr) -{ - /* TODO: Make this something that isn't fixed size. */ - char *s = malloc(1024); - size_t len = 0; - - if (!s) { - return NULL; - } - do { - if (cpu_memory_rw_debug(env_cpu(env), addr++, s + len, 1, 0)) { - free(s); - return NULL; - } - } while (s[len++]); - return s; -} +char *softmmu_lock_user_string(CPUArchState *env, target_ulong addr); #define lock_user_string(p) softmmu_lock_user_string(env, p) -static void softmmu_unlock_user(CPUArchState *env, void *p, target_ulong addr, - target_ulong len) -{ - if (len) { - cpu_memory_rw_debug(env_cpu(env), addr, p, len, 1); - } - free(p); -} +void softmmu_unlock_user(CPUArchState *env, void *p, + target_ulong addr, target_ulong len); #define unlock_user(s, args, len) softmmu_unlock_user(env, s, args, len) #endif /* SEMIHOSTING_SOFTMMU_UACCESS_H */ diff --git a/semihosting/uaccess.c b/semihosting/uaccess.c new file mode 100644 index 0000000000..0d3b32b75d --- /dev/null +++ b/semihosting/uaccess.c @@ -0,0 +1,51 @@ +/* + * Helper routines to provide target memory access for semihosting + * syscalls in system emulation mode. + * + * Copyright (c) 2007 CodeSourcery. + * + * This code is licensed under the GPL + */ + +#include "qemu/osdep.h" +#include "semihosting/softmmu-uaccess.h" + +void *softmmu_lock_user(CPUArchState *env, target_ulong addr, + target_ulong len, bool copy) +{ + void *p = malloc(len); + if (p && copy) { + if (cpu_memory_rw_debug(env_cpu(env), addr, p, len, 0)) { + free(p); + p = NULL; + } + } + return p; +} + +char *softmmu_lock_user_string(CPUArchState *env, target_ulong addr) +{ + /* TODO: Make this something that isn't fixed size. */ + char *s = malloc(1024); + size_t len = 0; + + if (!s) { + return NULL; + } + do { + if (cpu_memory_rw_debug(env_cpu(env), addr++, s + len, 1, 0)) { + free(s); + return NULL; + } + } while (s[len++]); + return s; +} + +void softmmu_unlock_user(CPUArchState *env, void *p, + target_ulong addr, target_ulong len) +{ + if (len) { + cpu_memory_rw_debug(env_cpu(env), addr, p, len, 1); + } + free(p); +} diff --git a/semihosting/meson.build b/semihosting/meson.build index 4344e43fb9..10b3b99921 100644 --- a/semihosting/meson.build +++ b/semihosting/meson.build @@ -1,6 +1,7 @@ specific_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_SOFTMMU'], if_true: files( 'config.c', 'console.c', + 'uaccess.c', )) specific_ss.add(when: ['CONFIG_ARM_COMPATIBLE_SEMIHOSTING'],