From patchwork Fri Jan 17 13:42:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 858183 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:cc8:b0:385:e875:8a9e with SMTP id dq8csp705163wrb; Fri, 17 Jan 2025 05:45:19 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVHBoXXGT+fVAJ9YRsB8qX+WDjY9sHmg0N9ogNL83kmeqfsq/wnLt2OqgP9b8002eqFgCpcbw==@linaro.org X-Google-Smtp-Source: AGHT+IEXDtatCEENunZD9lmxgk0XJMygj6eIPbJ43aRw9ju5IYwvAAzQ+RLUxh50Ax8FxWqZlbli X-Received: by 2002:a05:6102:5106:b0:4b6:3700:d74a with SMTP id ada2fe7eead31-4b6909bd57fmr1733315137.0.1737121519449; Fri, 17 Jan 2025 05:45:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1737121519; cv=none; d=google.com; s=arc-20240605; b=CgZLfSzjFJmq/8yJ543ElJyGnqWdUghE08mNZR2etc121cxwJZcOKgEGkSDlNpjhDz /8/kQ9UlNUArf+evACzOqKfQs4xtXkoh52s69TMSqRmOq3s1/cY4HY6PqHNbFBNQHT3i sr9Ng4I6K8IXHkDim0GmrKmzUqL5tPj1HqwGQdd4jsnKsFo0kWBH510OxwMN7XMiGM3+ 3mM2HcBWfqOVQS9eBknSOXavPsqk3cSBq9NrpErGW17kF9G34g21ylJ8uPafgijIL8Mh xi93ekk9MMx172OAbGxPATFx2bGOiinViQv1maxTz+QY05dUOXurdsyqN8Dy3ItaCz4x 1u+g== 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=HvyvcMT5Ik5FGrm6V5mlorp+UlJN6JEGaToeVYNLLOk=; fh=Blf2oUU/YG0QI3K9EaXy3qgSFUqguV8JMcvhxUv3o9M=; b=JvOwgT8y5a79fzxDNdYHslD3f/QFbusaz3jHW45ShVtiUsBFbBGZaZqa3zEOdfdYv3 1kH8Kmm8Ybn0uq6Rs/48CwDAsDS9pK+kzYzcWC5Uomq26MPr+5ChmJnI3Vau50dp9SmY WlDWIIXAZV4tnVWiJqv/cQV80UokiVkGAaPebgKmflZPr8wOcbRFX3jY+2vQKuSLhDcJ SEkMC+o3rnMFEGU2giL83TfoNk3xKgk7QmYyUOvV7YmViai9qwPjckUuoE4/yfXUdjod Ez94ac9cPreO363q006I57Ln/16ZGtswLtzlEqCJtWR7o5kshisErMqTWpe0LyRzfzdu vDgQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eUqBOWaN; 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 ada2fe7eead31-4b68a1b0608si846541137.110.2025.01.17.05.45.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 17 Jan 2025 05:45:19 -0800 (PST) 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=eUqBOWaN; 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 1tYmdA-000189-Bf; Fri, 17 Jan 2025 08:43:24 -0500 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 1tYmcu-0000x2-Gw for qemu-devel@nongnu.org; Fri, 17 Jan 2025 08:43:08 -0500 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tYmcp-0002CR-1g for qemu-devel@nongnu.org; Fri, 17 Jan 2025 08:43:05 -0500 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5d0ac27b412so2822743a12.1 for ; Fri, 17 Jan 2025 05:43:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737121379; x=1737726179; 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=HvyvcMT5Ik5FGrm6V5mlorp+UlJN6JEGaToeVYNLLOk=; b=eUqBOWaNpZszfBaqsHYyNC/Zqb9cJv1JtN3sMKDijEeuYGl3O+qgdZuOynEPskL37y WKjwK9xL406c3JAl7EjfapiY2oDFdUGNteUNNT/ZO4Xh0OHMSNmmQbvhP1DyTHUZwGXQ dyw+0RzbCcre/Y7xB7VPPOgpn4TkC+9YEFqW7HDTWHl/ROdxPcto0XHlxkGWHIx8ufzO /VAzwW1iSYE22QhdvRNejcAn9IvGr5DcMFABXOvcCt56xbJ3enGFWjmjapw/WhJcVWWo H+MBwuDjlVTe214Mbm0MNlqoD5h32k8u13IgXYfpdoLGKE3zdpTGwpjFw65xV6hKNbPY rucw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737121379; x=1737726179; 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=HvyvcMT5Ik5FGrm6V5mlorp+UlJN6JEGaToeVYNLLOk=; b=X9FXAv45vIa2LS8eYroHl4UWZTh2mhMcr/jS7IoDaS1ac6ur4Z8fkDsJLEvWunOa/C cMY26HVYho9udfMmUer3L+wR4ikDw4aKwepLU0cuwyf47KeTkmJcyFEWu688KeyJAo1E lA5gE8GESeCB/LdDys+vhYxFHx7Htp+2vXT/zANPvECcvQ/wXxvweyy8VIObqOwEBr2W zOomB548CxuBHNQROl2/ETiDzGEPbS32PI9NPB8CVue0N6iTU+qTSjLIUs+ZRRmk0bTm XHwYII2p8xDDYK3HaWWKcNGo8vkpV2xzTD16PTR0dUmBxEaGqHoVGbkbJcA2uf7yKfH5 iJew== X-Gm-Message-State: AOJu0YxH7V9rpKCBXqoxflC3xXOs/CxBAnYVKcBonf/CCbJfUnU3xVSy jqHx6k5JdieRv9NNecESS2drLlR7AEaNa0JXxea+BYklHRGl30FAbCspLo7qC78= X-Gm-Gg: ASbGncu3k2nE+WVwHUpVrJQxHzkd2ePSsGM3uZQMTlXNookcPxF619yqTpBt9LcpFHH RdIm+Q0CjQOKoWEc2fWeRWITqPKhgZmEAPE/odDSmxh7aBa1iK5MR27WS3I86VHTrowEoZQVfA4 gtLYYMcG2lQr+V/uqS7q1LL5mMqhdVlopEWemB9O6o5mqOVHExzz8RkqAmtLznbwBpklyI3iOFm RWHUYc+Y2y/zuHXy8z+uRGUyaJR+yV5gxQCkO7P7diTx2AgqK0oT0k= X-Received: by 2002:a17:907:7e95:b0:ab2:ffcb:edb4 with SMTP id a640c23a62f3a-ab38b162801mr210575466b.25.1737121378573; Fri, 17 Jan 2025 05:42:58 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab384f87d5asm170559766b.124.2025.01.17.05.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 05:42:57 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 1300C60853; Fri, 17 Jan 2025 13:42:57 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= Subject: [PULL 02/37] semihosting/uaccess: Briefly document returned values Date: Fri, 17 Jan 2025 13:42:21 +0000 Message-Id: <20250117134256.2079356-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250117134256.2079356-1-alex.bennee@linaro.org> References: <20250117134256.2079356-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52b.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 From: Philippe Mathieu-Daudé Since it is not obvious the get/put_user*() methods can return an error, add brief docstrings about it. Also remind to use *unlock_user() when appropriate. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20241212115413.42109-1-philmd@linaro.org> Signed-off-by: Alex Bennée Message-Id: <20250116160306.1709518-3-alex.bennee@linaro.org> diff --git a/include/semihosting/uaccess.h b/include/semihosting/uaccess.h index c2fa5a655d..6bc90b12d6 100644 --- a/include/semihosting/uaccess.h +++ b/include/semihosting/uaccess.h @@ -19,41 +19,96 @@ #include "exec/tswap.h" #include "exec/page-protection.h" +/** + * get_user_u64: + * + * Returns: 0 on success, -1 on error. + */ #define get_user_u64(val, addr) \ ({ uint64_t val_ = 0; \ int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \ &val_, sizeof(val_), 0); \ (val) = tswap64(val_); ret_; }) +/** + * get_user_u32: + * + * Returns: 0 on success, -1 on error. + */ #define get_user_u32(val, addr) \ ({ uint32_t val_ = 0; \ int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \ &val_, sizeof(val_), 0); \ (val) = tswap32(val_); ret_; }) +/** + * get_user_u8: + * + * Returns: 0 on success, -1 on error. + */ #define get_user_u8(val, addr) \ ({ uint8_t val_ = 0; \ int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \ &val_, sizeof(val_), 0); \ (val) = val_; ret_; }) +/** + * get_user_ual: + * + * Returns: 0 on success, -1 on error. + */ #define get_user_ual(arg, p) get_user_u32(arg, p) +/** + * put_user_u64: + * + * Returns: 0 on success, -1 on error. + */ #define put_user_u64(val, addr) \ ({ uint64_t val_ = tswap64(val); \ cpu_memory_rw_debug(env_cpu(env), (addr), &val_, sizeof(val_), 1); }) +/** + * put_user_u32: + * + * Returns: 0 on success, -1 on error. + */ #define put_user_u32(val, addr) \ ({ uint32_t val_ = tswap32(val); \ cpu_memory_rw_debug(env_cpu(env), (addr), &val_, sizeof(val_), 1); }) +/** + * put_user_ual: + * + * Returns: 0 on success, -1 on error. + */ #define put_user_ual(arg, p) put_user_u32(arg, p) +/** + * uaccess_lock_user: + * + * The returned pointer should be freed using uaccess_unlock_user(). + */ void *uaccess_lock_user(CPUArchState *env, target_ulong addr, target_ulong len, bool copy); +/** + * lock_user: + * + * The returned pointer should be freed using unlock_user(). + */ #define lock_user(type, p, len, copy) uaccess_lock_user(env, p, len, copy) +/** + * uaccess_lock_user_string: + * + * The returned string should be freed using uaccess_unlock_user(). + */ char *uaccess_lock_user_string(CPUArchState *env, target_ulong addr); +/** + * uaccess_lock_user_string: + * + * The returned string should be freed using unlock_user(). + */ #define lock_user_string(p) uaccess_lock_user_string(env, p) void uaccess_unlock_user(CPUArchState *env, void *p,