From patchwork Sat Apr 30 13:28:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 568097 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp7206221map; Sat, 30 Apr 2022 06:31:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBTTDzn8bKnRXe7ycx8sJY7Lu1xo7lhTzmkvTisF34ah/JbqAsh2VZCrr6cJG6+8HD6tke X-Received: by 2002:a05:6214:3017:b0:45a:6c33:2ae9 with SMTP id ke23-20020a056214301700b0045a6c332ae9mr3051008qvb.108.1651325507117; Sat, 30 Apr 2022 06:31:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651325507; cv=none; d=google.com; s=arc-20160816; b=GQI6cSIJRNFkO/vwW6ugR+al4P71Ymr2qRRNgZM3UV1sxUUc4oi+Wugt0dPBIaJsfG RKB7x1YP2rAITcw2PhgM+AHuDSkJ1tOMos8CUZlWd012wZbE21vApRJmQuIsXLjSbD3z GJPwQjp98+F+b4IhxFj1VYGKEOssUfqMbhSbW+x4SKDNqe7cjrzsWbKV9kc8lQy+9y4/ hLvwQyIRNvzfpE/rmHwy/IfF03ikyjlZz6E+dMytxJiemYY7FiYn2Rz6uu9LFnXlsCOU WD/kW5p1xt/dL1xdjUorFvvZ4xL27xTLSrSzQOtpU0sDUTanWvq8LdwmbB3veAF6YKOF XECQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=x8BxBi+dxwcNinwm6heDyciERoofO1ytsNZ6JDtu0RE=; b=pOYDXUg4+fsulOxpIbgQ5gb27gDai5+jRdA9jnxk4nqh+B8mZLfMmU2KNM058x2W7S c74Cy7858jOq3naZ0k0Iavf7E1cgvPdJ8sLLNOBrAhWghO+epNGp76YrsqpbOpcnbKhM m6yu0nXyYytIvIqsRBtzaTbH//P8twoh/pHLNKodj2ZRruE85KI53vlVV8MwCWb/JfG6 dplxp82JznA2UjFoI+MAZBhEtZptSKC7VwSq+fx5MJ1fOeed4phWVidWr7yLS7t2u++i Nj83SFHtYY/61mfv99B893RIDMRhcclNO1f5ElbHTA43dNBeeSkM5gXCBk1AIHiDDiZD 2hrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PHR6CAiP; 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=fail (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 a17-20020a05622a065100b002f1faea49d4si3932677qtb.656.2022.04.30.06.31.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 30 Apr 2022 06:31:47 -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=fail header.i=@linaro.org header.s=google header.b=PHR6CAiP; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nknCM-0004m7-Gv for patch@linaro.org; Sat, 30 Apr 2022 09:31:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nknAN-0004gP-0k for qemu-devel@nongnu.org; Sat, 30 Apr 2022 09:29:43 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:38859) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nknAL-0006D4-4Z for qemu-devel@nongnu.org; Sat, 30 Apr 2022 09:29:42 -0400 Received: by mail-pj1-x1036.google.com with SMTP id cx11-20020a17090afd8b00b001d9fe5965b3so10813378pjb.3 for ; Sat, 30 Apr 2022 06:29:39 -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=x8BxBi+dxwcNinwm6heDyciERoofO1ytsNZ6JDtu0RE=; b=PHR6CAiPt4gWta5B4Sg3UU7KLvMxEQMWB9HS/c4NZh6LDvzlpqfDzmWp22ponf8Pjo Cfl859Bvb9TxocU+rmhUcwj1pV8Og5SQrxpQwGGCrfh6VUmL4cFYap7tql5NHM7/hEdU bHtWw+gODtn4FstY9KFm7IXt5MH3Hf0rB6Ohu/24p+oui0fKkus1KGYvXdxdDMJ7todH ZrMUh1saaGwoCKcXSE9ScZUhmc0+yZtCzCL5h+/5LT64zyg8ai1G4lkd+cWHzU+X+uak Pa7DEhWITHhJd1VUkinj9iOvo33txd8c4ivaUH4t4FquwIporabUI+RBnfMSDATyj7vI JMjA== 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=x8BxBi+dxwcNinwm6heDyciERoofO1ytsNZ6JDtu0RE=; b=792OZE/R1Mw0x8NfMgi21AxGOmwustseVIDo3dEoe+cgX/ANPnBzdvl/brnybL7vxJ Y8EoFdhlagQsiw/TZAu1IVCw3NazicH7PeyUSjnRieNy6lBhxoQOJ5H4fMZ6d3r8+Uu/ GJ5kvXXs6zO/FgAAWosipvQkdc2Yrw5jU60guVl4gYVFQUQn8hLL9nSAYjrh6PHqTiv0 TcunjGbQAaFS1GuNeHQQFe7DShuxakLkRrjqfgGNNo69/dV/vF8a1gFQC7uF54TmrLU8 StGt1DISymDsaXEc9f3H7xV+5Xwwmehnel8JyfYJfgH9j3w27l4lBO/1vgBz5PYZiUfB qmbA== X-Gm-Message-State: AOAM531c8LydSyxAYEK6hW1e+nBCEIekqRhAsWXEykW2QFMMtC3zrSg0 vpciMV3e5KfuoCcUhlcQHu6O9SshKub/gA== X-Received: by 2002:a17:902:edc5:b0:158:4065:a5ce with SMTP id q5-20020a170902edc500b001584065a5cemr4019540plk.55.1651325378263; Sat, 30 Apr 2022 06:29:38 -0700 (PDT) Received: from stoup.. ([71.212.142.129]) by smtp.gmail.com with ESMTPSA id x5-20020aa793a5000000b0050dc7628201sm1522606pff.219.2022.04.30.06.29.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Apr 2022 06:29:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 04/43] semihosting: Move softmmu-uaccess functions out of line Date: Sat, 30 Apr 2022 06:28:53 -0700 Message-Id: <20220430132932.324018-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220430132932.324018-1-richard.henderson@linaro.org> References: <20220430132932.324018-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.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: , Cc: crwulff@gmail.com, alex.bennee@linaro.org, f4bug@amsat.org, laurent@vivier.eu 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. 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'],