From patchwork Tue May 3 19:47:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 568962 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp9774919map; Tue, 3 May 2022 12:58:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmS6WhYGByESRUE6KMn2YRqCyvptBzpTg1zWQfylh93cRMmEMaTVpsA+jovgx9nQ1M+l8h X-Received: by 2002:a05:620a:24c9:b0:69f:400f:f59c with SMTP id m9-20020a05620a24c900b0069f400ff59cmr13379842qkn.466.1651607919281; Tue, 03 May 2022 12:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651607919; cv=none; d=google.com; s=arc-20160816; b=JjRyDXFV3iR7wIvoEQXPXFyD050S7zzJTWpgIOnXzaTkICvjctyt4t0afpI8LoPAdV xBE2dQiq0Ap0GByfDwLUEsaFmh6ptv/1klTvVjDFlcPDTEGHNn0Xhua+XtKjvtRMy1oB L0cy+KPWrjUqWQuP0UcsYTo+9MgiQ5ThicJ1NSXPs1WfgwSprr+axH5FZuf3o8ou5b9v 1imooQm2HceVIcH9JP+hpPhc1HxlyYCvVBCJPdShIprvrL9oWC7PVcsgCd2pfjAWlMmU 49UZSbAue+Pczuu1Z/4RYGDTJJH49zZQAaPe/PVvf4t417/okQonz6YmP1Dv17u/2NeO 5ELg== 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=x8BxBi+dxwcNinwm6heDyciERoofO1ytsNZ6JDtu0RE=; b=iy7Iz+g5HGAF2W2mVohbJY6yNnNrGJfCGSzz/1YHJQv1Sf0xT9Ov5PFdNg3wyu+NDK gkigyISY1aHPCH+uUApNA9SCqepeoYHM7m8DXIlrm6kuHeBXjS1Isu4LQBox3kb8CARX MLF5w/4m2I0lOvuuBX5F0bd9g4hP4CloVv3JWeep5De4AHwNK+m3DMtCXOrYSY1qVWXM G4SQV2jo7ZO54LlC65x0Id+9uG0auX6dXyzcR53WxCuFh0420SaVP6TfARNj5WhsnH2I 4fFtG9+NGntwCTogYIoTLWBTC09fGlWG0BE0Pph1cft+5Ptp+UK5ycZ6yza9pVKQPH5V /t/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Ap8tlY1/"; 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 dt15-20020a056214098f00b004564ec055edsi8031426qvb.237.2022.05.03.12.58.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 May 2022 12:58: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="Ap8tlY1/"; 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]:36282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nlyfO-00031e-Nv for patch@linaro.org; Tue, 03 May 2022 15:58:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlyVw-0000wK-4A for qemu-devel@nongnu.org; Tue, 03 May 2022 15:48:52 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:44583) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nlyVu-0003WE-D1 for qemu-devel@nongnu.org; Tue, 03 May 2022 15:48:51 -0400 Received: by mail-pl1-x62a.google.com with SMTP id j8so15854448pll.11 for ; Tue, 03 May 2022 12:48:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=x8BxBi+dxwcNinwm6heDyciERoofO1ytsNZ6JDtu0RE=; b=Ap8tlY1/zvmj1NdsBqP7L3lr7TWoj7dETfMi8P6lmSeifw+nXAEx7F18kBuibwXh4A /YFgtTuvk1q792G/pTJQyvlDj/HdUEyeGVIXR5Oaua10WZHmEvCtrCBeQuJSS0ASZfQQ PLkw+hzRvDqEcAt+tw7dSgfRpZCDZY15nndRk+ZFoW8KOYP8Jr6I3aRkyM6op698SWvT w+kWhwKfy950+ULD3aAT11RCpI2jJluDX9e0ezUHD+rg/kPEzJFylDKquYsFDdxZzWbG 1rLRiortOzOWkCDFj5E4lmpeF35g9sUvplOcsi8ap1Z5zJnJjoA8+TQE+tuJ3wqTARsa zWAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x8BxBi+dxwcNinwm6heDyciERoofO1ytsNZ6JDtu0RE=; b=4AMQsKaROxFo6hDGu9nu4o6oWsvOYpA7RZebOZOOdHFnMZBxZDlzu32jxjuPSeKD2U XCUNwnh12b9JHJ+FRXaabqfMnzBbbTZr2NgBo60LgqHvZPrn564y/O6rkSWjGqWMm6S5 DACwyqUck2tgiQZtFY6ElIyof6WWNMhUHDCjeDijlUhgcVRMbreR5ojbD24xQ0tbfVsA hB1w5430Q4CtxpDtWjF58/bwOrJHjZjWQSTeXHl74bOllltsWAtwbfKIgmvc4LTKqLoZ HJM2PuHhTkHZxkasa6n0E+ZNMduOOvYuT/oWxEh2zS2ETi9iw+/wCnHYdqF5CgKrZPwD qq+g== X-Gm-Message-State: AOAM531f+Xux1ikuGRFpNCptx24RkSzVTPaHtIafrc0UWPKh3q8Qh1Nq IYXwdbNWR1iVYCo/gv+pEeOQaeuvIMb7ew== X-Received: by 2002:a17:902:9b92:b0:158:9b65:a78 with SMTP id y18-20020a1709029b9200b001589b650a78mr18564198plp.53.1651607329039; Tue, 03 May 2022 12:48:49 -0700 (PDT) Received: from stoup.. ([71.212.142.129]) by smtp.gmail.com with ESMTPSA id p11-20020a17090ad30b00b001cd4989fed3sm1712383pju.31.2022.05.03.12.48.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 12:48:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 04/74] semihosting: Move softmmu-uaccess.h functions out of line Date: Tue, 3 May 2022 12:47:33 -0700 Message-Id: <20220503194843.1379101-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503194843.1379101-1-richard.henderson@linaro.org> References: <20220503194843.1379101-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, 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. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- 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'],