From nobody Wed Apr 24 05:32:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616247584; cv=none; d=zohomail.com; s=zohoarc; b=CqG+8ptQmUqiXnu5QoU30FKbRaa0N6E9IkHmVoSXjV1QSxCna9yyAMVCDpt2eygaZqfJLwzfx2vIBunHjC5g5mkJSh6HVKgBXmK/ZVdtXRMEVkftEIUlerSINQxbs0WqPALuJfKkaAiHNqowSsG/oVdOhD0yDTI+cU9wRgWXYJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616247584; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CCjBtNHV/27BIqfm5dJoDvU/LJdm3qeSBui9tlj/n/s=; b=Ykz1ZFi91O9YhM6J8nKFqfR1c2YaqtNpP0iK1UkBrVMrzxbyPxBBVRt1Pr12XSP7zwIGxa8/cNFoFwNJkb5w/w9R4jvQl4Fc8oJ5ThznCijYKBrkGL3/K3K1YivSw+FxEvVUt0qmKx7PLeLJSZI/waof5vHiWZZLPvt1zY+If3o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616247584978686.8895135950862; Sat, 20 Mar 2021 06:39:44 -0700 (PDT) Received: from localhost ([::1]:49160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbpP-0004it-0N for importer@patchew.org; Sat, 20 Mar 2021 09:39:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNbn4-00032D-3G for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:18 -0400 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]:41547) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNbn0-0004EF-49 for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:17 -0400 Received: by mail-ej1-x629.google.com with SMTP id u5so14057817ejn.8 for ; Sat, 20 Mar 2021 06:37:09 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id be27sm6288678edb.47.2021.03.20.06.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:37:07 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id CA0091FF87; Sat, 20 Mar 2021 13:37:06 +0000 (GMT) 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=CCjBtNHV/27BIqfm5dJoDvU/LJdm3qeSBui9tlj/n/s=; b=WH2HOUppdSfGcPB6C2W+jWVmQ4Wyzeu27UvxMoqs3QJzOcLQJTpQXTTTr/FSX7lGOe GZv08gknIjva5crlXW0uWLjkwmZyDXMt/BTS/XQzNwKnO1nTeucWITwrJiz9cRZsDEFm HGRS7bvzXQsEGpsYbGsOkmj3pTqVhhjQD8dDJCQNHtq69WeyjSBbdydcmiCG4xYbeIfP wgJ36SwP0v2/Ph1nz2zhCxR5zXEK7iSpHav9rWoEgVZ9hTXoAutNTMqZ9UHEznk8/nNt iTr+UbftlM7iHV0FX3dqZHGDyibLWiVR+GE5GXGBg537k9nkoETCtUAQqw/cS+pBoZ+K h25Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CCjBtNHV/27BIqfm5dJoDvU/LJdm3qeSBui9tlj/n/s=; b=ZoRQ1ECGthf/jo0BjFUJOjg6VT3W+l0rUxgl9KmgCALARpeiE9i5bY1k4owA0Bn5M5 O3jkhuDRPvrkbI1SU55zuzHEdVIV1WkthwkxyZWhg/KXVGOEn+guxciUABP+whjzhX5z 5xGGHMGKolmGzE8EV2WXR7v8ltOWDyPaCdvYVHvKcdXrHhLHq/gR7MADZLEA0OACmcVn PLkxpQNUalvV/4Gt8Yts+YLvy8IJcTtIRCZfr3y41UoTMuhxghaIl+2immIHS12GFZn9 oEXUV7/ntxmGN91lZIfKkijUTp+5psQXzcKUBvyZbA/TM60rp5yq01KD43Lk1morGFqn naaw== X-Gm-Message-State: AOAM530NikgV1SQK/PBbKtfbnQknV4vyLHamuN5Cbp/BrnA/qtYJ3SaD pBoFjCwZBvrZPmsGBV0/OItxvw== X-Google-Smtp-Source: ABdhPJzK3JMP514sh1Q8o0M3KUDqIJoOA6mBdczk6zUmrmCrZWEr3uOk7IxQM/KK8VYI+Rs64mfU4Q== X-Received: by 2002:a17:906:1a44:: with SMTP id j4mr9883109ejf.401.1616247428722; Sat, 20 Mar 2021 06:37:08 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 01/14] scripts/kernel-doc: strip QEMU_ from function definitions Date: Sat, 20 Mar 2021 13:36:53 +0000 Message-Id: <20210320133706.21475-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210320133706.21475-1-alex.bennee@linaro.org> References: <20210320133706.21475-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::629; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x629.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Some packaged versions of Sphinx (fedora33/alpine so far) have issues with the annotated C code that kernel-doc spits out. Without knowing about things like QEMU_PLUGIN_EXPORT it chokes trying to understand the code. Evidently this is a problem for the kernel as well as the long stream of regex substitutions we add to in this patch can attest. Fortunately we have a fairly common format for all our compiler shenanigans as applied to functions so lets just filter them all out. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- scripts/kernel-doc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 4b19851b2d..240923d509 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -1745,6 +1745,9 @@ sub dump_function($$) { )+ \)\)\s+//x; =20 + # Strip QEMU specific compiler annotations + $prototype =3D~ s/QEMU_[A-Z_]+ +//; + # Yes, this truly is vile. We are looking for: # 1. Return type (may be nothing if we're looking at a macro) # 2. Function name --=20 2.20.1 From nobody Wed Apr 24 05:32:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616247586; cv=none; d=zohomail.com; s=zohoarc; b=aCrmGCmUiPjnoLTGYNUMUgk10H6SJDGrIkGys0/1jLSDwzFExUA5VqyJq2Qm4myg2MIzlBJOzeDWKlsYZdCRHozjym2tYnQ0SOIqjzwjvYPMxrv59EWZxDspSYNkWH4oviH4KzTLGe71KyXsKBBUVlUIvGa4WoQ6NGepDXiJumg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616247586; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qI7RaKP8t/8kWu2Q3Cb45ubBjt2y6/gFWrDLRt5E2Mc=; b=Ffu423/PrNti7MnQWnRWgGBsVTRzv9tXJrTzo/opZGIpiqXVB+gxBYXUgXErWSq11rAdxnO4fUorP6YojKecJ2f7Bg1JjDowwZ5iLW8zGV8T/me1qFHBT9AMCxOMg8n26jfZ1mAbby8xP4fdWy6DXb9QFliHbNYJISrky3TdqBM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161624758612414.525595436340723; Sat, 20 Mar 2021 06:39:46 -0700 (PDT) Received: from localhost ([::1]:49232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbpP-0004kh-Va for importer@patchew.org; Sat, 20 Mar 2021 09:39:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNbn3-00032A-SM for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:17 -0400 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]:45595) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNbn0-0004Ei-1b for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:17 -0400 Received: by mail-ed1-x536.google.com with SMTP id bx7so14012979edb.12 for ; Sat, 20 Mar 2021 06:37:11 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id i2sm6120086edy.72.2021.03.20.06.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:37:07 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DF5521FF8C; Sat, 20 Mar 2021 13:37:06 +0000 (GMT) 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=qI7RaKP8t/8kWu2Q3Cb45ubBjt2y6/gFWrDLRt5E2Mc=; b=hx+UJ8USWUegHtaFYV7gh417KuK4mwsCUcUsBM62IYYe8f5qSx398HPnoqP6UKdOgj AJvxYTu0AZ3QCCpqPkANPwxq8GqHVj94I+pY8hNPeF5pbRi+vz3fzZ/BtKM1J/BEWTyC SITk0ZbjJYG323bvMetoivkWpyX3sDEGmsXbyYoA3c/eNgvoBzSlLBMukmwG05GC904a o+QJH0giQ1AX/vptL/QGZ3mzfwzYO7XrqE2eCticXxT6ZYUU53LmiPvKfFw3PLgelsl8 2MxEjeCLhq+7pO8LHPdkZYBpvqVs0GeU1VntZmPPDwZmrqOI4Bvvb/WlXWyFCvsciv+y HT8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qI7RaKP8t/8kWu2Q3Cb45ubBjt2y6/gFWrDLRt5E2Mc=; b=g2PyAlu7IsDvA0j5gSR73pxky1fIldL00OLKV9TULophmMxo4Kdz1mIHC7bKRgktQV xle5lqU8PtFYw6wTlAVDYjzHKuUrxQdb94XJ3LhfbTKlHrs2tZESfLEePeAImmr2kkZL 2nXianLilvBRnS3jypS5dPx4MOWDgwIpE5kUBiJ+Q9NTbxQJEasUT3PhVBqN6k+iOKFK uQ9GZP3orXGe+F31qeg6cZ8UgVKjqYBW3/laCJNoJmoeX8RcVIKhh5tZ3KTCUCAa4AHV BQH5+h1d+LEqy4IDF+2boUtUl2hti9MheXFNReJssEQ+uu9mV3/MQUguvjFce5FJUyne iq1g== X-Gm-Message-State: AOAM531aN1efag2Xhpa29PkIHpirlVvaYAzkSlDI4Z6vpRQP9xMI84XC VPSyQqwimXoAylFJicn+qjCYYw== X-Google-Smtp-Source: ABdhPJyhH4sqpt6vCKQ2uZiQRomklsgcIW5nCoP4JKAfqtpm+lNANzUISPreGg/HL9dSmwhYD+GGSQ== X-Received: by 2002:a05:6402:27d4:: with SMTP id c20mr15658543ede.271.1616247430777; Sat, 20 Mar 2021 06:37:10 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 02/14] docs/devel: include the plugin API information from the headers Date: Sat, 20 Mar 2021 13:36:54 +0000 Message-Id: <20210320133706.21475-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210320133706.21475-1-alex.bennee@linaro.org> References: <20210320133706.21475-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x536.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aaron Lindsay , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We have kerneldoc tags for the headers so we might as well extract them into our developer documentation whilst we are at it. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Aaron Lindsay Message-Id: <20210312172821.31647-4-alex.bennee@linaro.org> --- docs/devel/tcg-plugins.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst index 39ce86ed96..18c6581d85 100644 --- a/docs/devel/tcg-plugins.rst +++ b/docs/devel/tcg-plugins.rst @@ -63,6 +63,11 @@ valid during the lifetime of the callback so it is impor= tant that any information that is needed is extracted during the callback and saved by the plugin. =20 +API +=3D=3D=3D + +.. kernel-doc:: include/qemu/qemu-plugin.h + Usage =3D=3D=3D=3D=3D =20 --=20 2.20.1 From nobody Wed Apr 24 05:32:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616247902; cv=none; d=zohomail.com; s=zohoarc; b=CZTbOilmyrDlT+/i/3ohV4oXuo6afqA5alwdFWad3cZNUXSP+0fQM5e4HN3zOyxJgZTARbVMT9804WoHJLiFhW1Rye7UJ7mUzaJ+s4KoOFQjoDonVANsOoUiYEkdjRloGqlgBsQa4LyeAUj0vvQdfWPksfpOr5uxyKC8OlpM/SI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616247902; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IM1oBayvdunRojoA3Pc9uJPF3Nk+3/AuR0/Svwaw3qQ=; b=Rz0O3/9ftCtRYJJwSzX0LKLRuFrRkzyted/KDRG9GDnuh/ldAVgmTV9VGxLr21iRl4kvzfoMnxAooiiJTLcCbH1+8LtPdCuv5slx8eaAX3+MUqPX1u4IZ9+v635aYxItYmuthh4eUGPw1nCIozdhlT9SNYrs22zTNx4Py1I2jn8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616247902187786.7977928013534; Sat, 20 Mar 2021 06:45:02 -0700 (PDT) Received: from localhost ([::1]:36440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbuV-0002gG-SR for importer@patchew.org; Sat, 20 Mar 2021 09:44:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNbn6-00035m-UA for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:20 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:41715) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNbn0-0004Eo-1g for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:20 -0400 Received: by mail-ed1-x535.google.com with SMTP id z1so14055211edb.8 for ; Sat, 20 Mar 2021 06:37:12 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z9sm6395435edr.75.2021.03.20.06.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:37:09 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0010D1FF8F; Sat, 20 Mar 2021 13:37:06 +0000 (GMT) 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=IM1oBayvdunRojoA3Pc9uJPF3Nk+3/AuR0/Svwaw3qQ=; b=FMVl8+T8V14SRgiP193wldryBjbcHXTun8kfuvY17B9vv4WL2II/NLqmjeZV0vpCiz mMjH/xFGzkpTqvtx8Gwlv1oeZU52xPmHFjRh9Qi9Ud5usTz5sK6n/2YoQbUHe/UkUkwP hps8JJAKlwHWOjwYrM/XputGzoWtzx8uYTA8f5EZq2Yes0B0mp4gJz8x5rNh0PNB0LBg oj121kCwN0a7i5g9WyGxivOpPaaqcZ1ikmkzKnylGWSi5YShZoyi7VORRjkZguFkW/7r TfgMtGGHLsZEN1r7ChpDov8FqKIO6Q2aJvvwiniXP/euN9f/Doqdy20sVgpbLoUTh5zL HN5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IM1oBayvdunRojoA3Pc9uJPF3Nk+3/AuR0/Svwaw3qQ=; b=f61KLt7FCzqKHv9hA4dFU8lpdL0EMBxYcGJyvHntxfAehtjC2eb72CoZO7u2hSLPQ0 XQPXUn5Ds2qkL2SY0WB31niGg/3zn6BSi+xEQgwtBU5Lm3QmWUAZ+UNr2MMlSGC9aS5s Qi+zkR2TGwicyHe7fVM9MK23CRrMaFBxZyGOH2PY8X5iTftJAu0IVb8zcDiL4VJoaZ1d a+mZTMCHLPTl4rsFkGCIQNxSn7TfVrpPXeWHU8Fc/Stn16yOAz+09ihFEUS4xdzrHTY0 GvTvU7Ym2kZA0HOJMHQv+2ojGxc2TFcOjPovZWTFYqIdci7573Q7EbQRV/vFiYoSNI8v sBtg== X-Gm-Message-State: AOAM532ApdKKuUaJZ/grMHw1IKuww3e8OTJw3Ik+Je6rtxw1E0n7Uqin O2ryd0xmVMVWRRp9K/EikXTQ779YPGJNM/xQ X-Google-Smtp-Source: ABdhPJycP4mv43F5u1Cboc1dB48eu55EvbxuaGZMp+gWEsVr/d1Dj/L0e93vdPmBbMlcC9UdoPR+kg== X-Received: by 2002:a05:6402:5255:: with SMTP id t21mr15585751edd.91.1616247431818; Sat, 20 Mar 2021 06:37:11 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 03/14] docs/devel: expand style section of memory management Date: Sat, 20 Mar 2021 13:36:55 +0000 Message-Id: <20210320133706.21475-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210320133706.21475-1-alex.bennee@linaro.org> References: <20210320133706.21475-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x535.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) This aims to provide a bit more guidance for those who take on one of our "clean up memory allocation" bite-sized tasks. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- docs/devel/style.rst | 46 ++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/docs/devel/style.rst b/docs/devel/style.rst index 8b0bdb3570..260e3263fa 100644 --- a/docs/devel/style.rst +++ b/docs/devel/style.rst @@ -385,17 +385,37 @@ avoided. Low level memory management =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D =20 -Use of the malloc/free/realloc/calloc/valloc/memalign/posix_memalign +Use of the ``malloc/free/realloc/calloc/valloc/memalign/posix_memalign`` APIs is not allowed in the QEMU codebase. Instead of these routines, -use the GLib memory allocation routines g_malloc/g_malloc0/g_new/ -g_new0/g_realloc/g_free or QEMU's qemu_memalign/qemu_blockalign/qemu_vfree -APIs. - -Please note that g_malloc will exit on allocation failure, so there -is no need to test for failure (as you would have to with malloc). -Calling g_malloc with a zero size is valid and will return NULL. - -Prefer g_new(T, n) instead of g_malloc(sizeof(T) ``*`` n) for the following +use the GLib memory allocation routines +``g_malloc/g_malloc0/g_new/g_new0/g_realloc/g_free`` +or QEMU's ``qemu_memalign/qemu_blockalign/qemu_vfree`` APIs. + +Please note that ``g_malloc`` will exit on allocation failure, so +there is no need to test for failure (as you would have to with +``malloc``). Generally using ``g_malloc`` on start-up is fine as the +result of a failure to allocate memory is going to be a fatal exit +anyway. There may be some start-up cases where failing is unreasonable +(for example speculatively loading a large debug symbol table). + +Care should be taken to avoid introducing places where the guest could +trigger an exit by causing a large allocation. For small allocations, +of the order of 4k, a failure to allocate is likely indicative of an +overloaded host and allowing ``g_malloc`` to ``exit`` is a reasonable +approach. However for larger allocations where we could realistically +fall-back to a smaller one if need be we should use functions like +``g_try_new`` and check the result. For example this is valid approach +for a time/space trade-off like ``tlb_mmu_resize_locked`` in the +SoftMMU TLB code. + +If the lifetime of the allocation is within the function and there are +multiple exist paths you can also improve the readability of the code +by using ``g_autofree`` and related annotations. See :ref:`autofree-ref` +for more details. + +Calling ``g_malloc`` with a zero size is valid and will return NULL. + +Prefer ``g_new(T, n)`` instead of ``g_malloc(sizeof(T) * n)`` for the foll= owing reasons: =20 * It catches multiplication overflowing size_t; @@ -409,8 +429,8 @@ Declarations like =20 are acceptable, though. =20 -Memory allocated by qemu_memalign or qemu_blockalign must be freed with -qemu_vfree, since breaking this will cause problems on Win32. +Memory allocated by ``qemu_memalign`` or ``qemu_blockalign`` must be freed= with +``qemu_vfree``, since breaking this will cause problems on Win32. =20 String manipulation =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D @@ -485,6 +505,8 @@ In addition, QEMU assumes that the compiler does not us= e the latitude given in C99 and C11 to treat aspects of signed '<<' as undefined, as documented in the GNU Compiler Collection manual starting at version 4.0. =20 +.. _autofree-ref: + Automatic memory deallocation =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D =20 --=20 2.20.1 From nobody Wed Apr 24 05:32:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616247585; cv=none; d=zohomail.com; s=zohoarc; b=fZMhRsRhcjC7JJHHHY9SxcMA6FhXZGSsG6NOnU5bblNVcxqyuruYwqLmuCtknYs0vuTVZYI5WimYM3PLoxh+9BTC+OSPXfFEkmtM44pe2aLtz335nJ8vkJb3ju4iYPa1g4yOrljJobS3+U33DsIt5R3OvQFSYpewiRVoXPcxlnw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616247585; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZwBf9UIhW9LVVf2kZJVAVnDApoNAfLOpIH7Z6bvZYNw=; b=izuZCgx7bJb8Wj2a/5v5w+P4QyvmEf6Wmi11CL/cpEtpr1EYVDvClYaKbaeO6AYF/NviRbg26DImlpqYe9LV9kem4Rqi4qTLy7L2ynV75lvi7pdcBka9neGHQugaXVvQOoOhvAYUZkFCAQEJHGUCo/Qy0zsdXv6BrAL7m9QvLsI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616247585779708.8366855336054; Sat, 20 Mar 2021 06:39:45 -0700 (PDT) Received: from localhost ([::1]:49270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbpQ-0004lb-Iu for importer@patchew.org; Sat, 20 Mar 2021 09:39:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNbn5-00032j-Hu for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:19 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]:38476) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNbn2-0004Ew-92 for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:19 -0400 Received: by mail-ej1-x636.google.com with SMTP id r12so14060965ejr.5 for ; Sat, 20 Mar 2021 06:37:14 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c20sm5375265eja.22.2021.03.20.06.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:37:10 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 162801FF90; Sat, 20 Mar 2021 13:37:07 +0000 (GMT) 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=ZwBf9UIhW9LVVf2kZJVAVnDApoNAfLOpIH7Z6bvZYNw=; b=p4TgbYR9DA+frXqzZiviPpxgOxbbTsswR/yerONWvcspDzOIrslPW5NmsvVQEJPKOX yW01BNYnKbn0pFfRlyfdmm4k/J+t5XeaByqI4Sy3zQcFLlor9+92Ee5ZAxPjiQiEbk8V 8m6pjcOZFzzunwFPQytBwF2PkhOojHn4oWAMiq7vgeShgyfoCUuZwyJEtzlkwkABbw8L TXMb/rI42IAf6Z7z0UQ6WJfeqAtUo7XuvmeWoFCO4byKWkrqeEb/XP8dID8Q93J/11O/ ILd9avknqYiZZ1SR+h6JE1ZyDOs+/nXOWTN6aV922FVZyfFQDb7AtZuLxqAD8OVD89eO T1tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZwBf9UIhW9LVVf2kZJVAVnDApoNAfLOpIH7Z6bvZYNw=; b=mk6GzFH/BSvd8QHWpuW15xQx7HEY5eI0x8M0L4PoBWi50kqFgasB8QLQLVD5J5LkWh NBR8k5aUH+u5yuc69IOHSN6S3mXlD9QD0Guve9codEqIkZ/dNT1z8Ph0GKz739HyReOz ENTmz77kWNwounuJ2JLGecbmYwJcvAFbu49NRp+Z8NFUuSAjCn9kLGYXX55ij0Jq26wm H8cvwiwvBzQMd4PkU/1Axu8jknnW1n1E1WRrNdwU/fAQe5qcG8FwjCo37iMNjysf445f 9UKGeAoQtnRw93kJscIv3YNVRXg/1/FfGg5X8YNa0ZfteBRbyO3BHkjMw5K7Bz1VkONg qeWw== X-Gm-Message-State: AOAM5311xm/nu2QA6SHAoX3F3J8ZInvEmU20w3kbqSXEQNeAgTda66/G 7r7u+u52flT/Qtu7++HS+Kjf+w== X-Google-Smtp-Source: ABdhPJzRd0Y4UV/IuARYSS2gHFkNAiUKGKomDWJj1nubnFYQzPIRU4wR/SCgbGilgvS2Vm68rWvkiA== X-Received: by 2002:a17:907:3da3:: with SMTP id he35mr9668684ejc.148.1616247433691; Sat, 20 Mar 2021 06:37:13 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 04/14] tools/virtiofsd: include --socket-group in help Date: Sat, 20 Mar 2021 13:36:56 +0000 Message-Id: <20210320133706.21475-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210320133706.21475-1-alex.bennee@linaro.org> References: <20210320133706.21475-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x636.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Connor Kuehl , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Dr. David Alan Gilbert" , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) I confused myself wandering if this had been merged by looking at the help output. It seems fuse_opt doesn't automagically add to help output so lets do it now. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Connor Kuehl Updates: f6698f2b03 ("tools/virtiofsd: add support for --socket-group") Message-Id: <20210318100911.16261-1-alex.bennee@linaro.org> --- tools/virtiofsd/fuse_lowlevel.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowleve= l.c index 1aa26c6333..58e32fc963 100644 --- a/tools/virtiofsd/fuse_lowlevel.c +++ b/tools/virtiofsd/fuse_lowlevel.c @@ -2450,6 +2450,7 @@ void fuse_lowlevel_help(void) printf( " -o allow_root allow access by root\n" " --socket-path=3DPATH path for the vhost-user socket\n" + " --socket-group=3DGRNAME name of group for the vhost-user= socket\n" " --fd=3DFDNUM fd number of vhost-user socket\n" " --thread-pool-size=3DNUM thread pool size limit (default = %d)\n", THREAD_POOL_SIZE); --=20 2.20.1 From nobody Wed Apr 24 05:32:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616247743; cv=none; d=zohomail.com; s=zohoarc; b=EdfBqkSR+PxQyOuUGD+kApxCuK3ZgHDw0JMpr24kXvDiRM+d91VzsKyIwq9XGDOazclraOP6Hq3luJlImvz6RhBHux8n4ku3nKnm7Xfofc/n3DZZTlHmLkbzkbPITVfcGlLj4Es6IsyW++g2FTRK3GyKCl+9C2pA5eO4gMUmIuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616247743; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tlo1IH59kp2yoMWTg8V5jw19LmnpM+/SiJZ1CFO2rII=; b=dSSK2sBMdBgxY24D98VJcq0i+2kvvgCixJAjK6an8bcZOkHPfsj3ISuMQz/k4oIbJ0T9Wn6c+hnpCKPYk/d3WluhqSqKiB+e8ammwGkePPKcscz6aillNI/Sd6wrZHeJr1TA6nblZ/QKPUPph4De1ZDxYdHmSHtyfemwkStjI6M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616247743920540.3655023829995; Sat, 20 Mar 2021 06:42:23 -0700 (PDT) Received: from localhost ([::1]:57716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbry-0008E6-Qk for importer@patchew.org; Sat, 20 Mar 2021 09:42:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNbn4-00032M-OW for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:18 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]:34604) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNbn2-0004FZ-8w for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:18 -0400 Received: by mail-ej1-x636.google.com with SMTP id b7so14066412ejv.1 for ; Sat, 20 Mar 2021 06:37:15 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id d19sm6141500edr.45.2021.03.20.06.37.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:37:10 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3E7CA1FF91; Sat, 20 Mar 2021 13:37:07 +0000 (GMT) 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=tlo1IH59kp2yoMWTg8V5jw19LmnpM+/SiJZ1CFO2rII=; b=x49+cRAcFXubblrJvw5DopgnHbru+G74p9GDNdgcyS9hX++bewseDOZyuHvDA0m+2i fjh6BQzC9ORHtpkihDzHx27888TC58a4PzJ2Vc+OFK/xSaerRTb5MXNdXz+ozqjDzNcU 6WZATnFX9YbsU7JeNtquXJwZw16X2s7KoJCTcApUH96+2DK+Uy+3KvUYm7LxOS1GEWr5 3pCkHcvXUI1sogvKeXvTWJrxYecOatNQ6/PlwOpEAelJuTnPrf7cJlc7tqT+QTVYVRaS gq/nRoV5Jzx5U54RkML09JhbCJP0FNhpthGd0mFA9CUwPT+y6rYRva7jQ/7GtID7hjV5 nq8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tlo1IH59kp2yoMWTg8V5jw19LmnpM+/SiJZ1CFO2rII=; b=E/rvcKGV/jXICfz54QqAwJxpB7585pxL/kCLBBK+VlUwavLxqkwK6cyFC2MLtrWCn9 js3BCglGWQwtjVCDWc0g0pX956D3Af2W/i27CpG8EN5HDh/WNEc9jdJuQ4viMwD5LGQC T+A5TvcZKJDk6K/ApD4BkM/3kPaWl7VVX7/wbdTJ1uy8vX6waUCZsCcUGcPx2QD2dEui Bg35dDUdY57OEKB53BsnBeiH3wBE4k7R5kDz/JIDyVPY7+ffSer1RuM1R3AFz7/Gxo7U K4+ovnYCKKGoJJgNQ9TvRS+TgxT3MSPOESCj5x/RsECkxijb4v9sjsdWvfGJcwG3ETlP ZiMA== X-Gm-Message-State: AOAM530qQB0MI91I1vvCIL9FD9k6g8YdASVkyPwmqD8F8mpestH7YboG +JbK9IMXOCprvXQO3D3Oqs/ALg== X-Google-Smtp-Source: ABdhPJyTGcEv4dxA3UNZb/2sl/0SwKomffepjPzNEi71kjk90bDiMDzzPBDJ1E2bzpG+rAj+PUOr5g== X-Received: by 2002:a17:906:5e01:: with SMTP id n1mr2951670eju.359.1616247434586; Sat, 20 Mar 2021 06:37:14 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 05/14] semihosting: move semihosting tests to multiarch Date: Sat, 20 Mar 2021 13:36:57 +0000 Message-Id: <20210320133706.21475-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210320133706.21475-1-alex.bennee@linaro.org> References: <20210320133706.21475-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x636.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "open list:ARM TCG CPUs" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) It may be arm-compat-semihosting but more than one architecture uses it so lets move the tests into the multiarch area. We gate it on the feature and split the semicall.h header between the arches. Also clean-up a bit of the Makefile messing about to one common set of runners. Signed-off-by: Alex Benn=C3=A9e Message-Id: <20210312102029.17017-2-alex.bennee@linaro.org> Reviewed-by: Richard Henderson --- v6.0-rc1 - fix breakage for semihosting/semiconsole-arm --- tests/tcg/aarch64/semicall.h | 18 +++++++++++ tests/tcg/arm/semicall.h | 15 +-------- tests/tcg/riscv64/semicall.h | 22 +++++++++++++ .../arm-compat-semi}/semiconsole.c | 2 ++ .../arm-compat-semi}/semihosting.c | 5 ++- MAINTAINERS | 1 + tests/tcg/Makefile.target | 3 ++ tests/tcg/aarch64/Makefile.target | 18 ----------- tests/tcg/arm/Makefile.target | 22 ++++++------- tests/tcg/multiarch/Makefile.target | 31 +++++++++++++++++++ 10 files changed, 91 insertions(+), 46 deletions(-) create mode 100644 tests/tcg/aarch64/semicall.h create mode 100644 tests/tcg/riscv64/semicall.h rename tests/tcg/{arm =3D> multiarch/arm-compat-semi}/semiconsole.c (93%) rename tests/tcg/{arm =3D> multiarch/arm-compat-semi}/semihosting.c (85%) diff --git a/tests/tcg/aarch64/semicall.h b/tests/tcg/aarch64/semicall.h new file mode 100644 index 0000000000..8a3fce35c5 --- /dev/null +++ b/tests/tcg/aarch64/semicall.h @@ -0,0 +1,18 @@ +/* + * Semihosting Tests - AArch64 helper + * + * Copyright (c) 2019 + * Written by Alex Benn=C3=A9e + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +uintptr_t __semi_call(uintptr_t type, uintptr_t arg0) +{ + register uintptr_t t asm("x0") =3D type; + register uintptr_t a0 asm("x1") =3D arg0; + asm("hlt 0xf000" + : "=3Dr" (t) + : "r" (t), "r" (a0)); + return t; +} diff --git a/tests/tcg/arm/semicall.h b/tests/tcg/arm/semicall.h index d4f6818192..ad8ac51310 100644 --- a/tests/tcg/arm/semicall.h +++ b/tests/tcg/arm/semicall.h @@ -1,5 +1,5 @@ /* - * Semihosting Tests + * Semihosting Tests - ARM Helper * * Copyright (c) 2019 * Written by Alex Benn=C3=A9e @@ -7,13 +7,8 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ =20 -#define SYS_WRITE0 0x04 -#define SYS_READC 0x07 -#define SYS_REPORTEXC 0x18 - uintptr_t __semi_call(uintptr_t type, uintptr_t arg0) { -#if defined(__arm__) register uintptr_t t asm("r0") =3D type; register uintptr_t a0 asm("r1") =3D arg0; #ifdef __thumb__ @@ -23,13 +18,5 @@ uintptr_t __semi_call(uintptr_t type, uintptr_t arg0) #endif asm(SVC : "=3Dr" (t) : "r" (t), "r" (a0)); -#else - register uintptr_t t asm("x0") =3D type; - register uintptr_t a0 asm("x1") =3D arg0; - asm("hlt 0xf000" - : "=3Dr" (t) - : "r" (t), "r" (a0)); -#endif - return t; } diff --git a/tests/tcg/riscv64/semicall.h b/tests/tcg/riscv64/semicall.h new file mode 100644 index 0000000000..f8c88f32dc --- /dev/null +++ b/tests/tcg/riscv64/semicall.h @@ -0,0 +1,22 @@ +/* + * Semihosting Tests - RiscV64 Helper + * + * Copyright (c) 2021 + * Written by Alex Benn=C3=A9e + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +uintptr_t __semi_call(uintptr_t type, uintptr_t arg0) +{ + register uintptr_t t asm("a0") =3D type; + register uintptr_t a0 asm("a1") =3D arg0; + asm(".option norvc\n\t" + ".balign 16\n\t" + "slli zero, zero, 0x1f\n\t" + "ebreak\n\t" + "srai zero, zero, 0x7\n\t" + : "=3Dr" (t) + : "r" (t), "r" (a0)); + return t; +} diff --git a/tests/tcg/arm/semiconsole.c b/tests/tcg/multiarch/arm-compat-s= emi/semiconsole.c similarity index 93% rename from tests/tcg/arm/semiconsole.c rename to tests/tcg/multiarch/arm-compat-semi/semiconsole.c index 6ef0bd2450..1d82efc589 100644 --- a/tests/tcg/arm/semiconsole.c +++ b/tests/tcg/multiarch/arm-compat-semi/semiconsole.c @@ -7,6 +7,8 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ =20 +#define SYS_READC 0x07 + #include #include #include "semicall.h" diff --git a/tests/tcg/arm/semihosting.c b/tests/tcg/multiarch/arm-compat-s= emi/semihosting.c similarity index 85% rename from tests/tcg/arm/semihosting.c rename to tests/tcg/multiarch/arm-compat-semi/semihosting.c index 33faac9916..b3fd16cd12 100644 --- a/tests/tcg/arm/semihosting.c +++ b/tests/tcg/multiarch/arm-compat-semi/semihosting.c @@ -7,12 +7,15 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ =20 +#define SYS_WRITE0 0x04 +#define SYS_REPORTEXC 0x18 + #include #include "semicall.h" =20 int main(int argc, char *argv[argc]) { -#if defined(__arm__) +#if UINTPTR_MAX =3D=3D UINT32_MAX uintptr_t exit_code =3D 0x20026; #else uintptr_t exit_block[2] =3D {0x20026, 0}; diff --git a/MAINTAINERS b/MAINTAINERS index 25fc49d1dc..b6e1b25b33 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3283,6 +3283,7 @@ M: Alex Benn=C3=A9e S: Maintained F: semihosting/ F: include/semihosting/ +F: tests/tcg/multiarch/arm-compat-semi/ =20 Multi-process QEMU M: Elena Ufimtseva diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index 24d75a5801..cab8c6b3a2 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -32,6 +32,9 @@ all: -include ../../../config-host.mak -include ../config-$(TARGET).mak +ifeq ($(CONFIG_USER_ONLY),y) +-include $(SRC_PATH)/default-configs/targets/$(TARGET).mak +endif =20 # for including , in command strings COMMA :=3D , diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile= .target index bf53ad0087..56e48f4b34 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -41,24 +41,6 @@ AARCH64_TESTS +=3D mte-1 mte-2 mte-3 mte-4 mte-%: CFLAGS +=3D -march=3Darmv8.5-a+memtag endif =20 -# Semihosting smoke test for linux-user -AARCH64_TESTS +=3D semihosting -run-semihosting: semihosting - $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") - -run-plugin-semihosting-with-%: - $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ - -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \ - $(call strip-plugin,$<) 2> $<.err, \ - "$< on $(TARGET_NAME) with $*") - -AARCH64_TESTS +=3D semiconsole -run-semiconsole: semiconsole - $(call skip-test, $<, "MANUAL ONLY") - -run-plugin-semiconsole-with-%: - $(call skip-test, $<, "MANUAL ONLY") - ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_SVE),) # System Registers Tests AARCH64_TESTS +=3D sysregs diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target index ec95156562..5ab59ed6ce 100644 --- a/tests/tcg/arm/Makefile.target +++ b/tests/tcg/arm/Makefile.target @@ -29,37 +29,31 @@ run-fcvt: fcvt $(call run-test,fcvt,$(QEMU) $<,"$< on $(TARGET_NAME)") $(call diff-out,fcvt,$(ARM_SRC)/fcvt.ref) =20 +ifeq ($(CONFIG_ARM_COMPATIBLE_SEMIHOSTING),y) + # Semihosting smoke test for linux-user -ARM_TESTS +=3D semihosting semihosting: CFLAGS +=3D -mthumb -run-semihosting: semihosting - $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") =20 ARM_TESTS +=3D semihosting-arm -semihosting-arm: CFLAGS +=3D -marm +semihosting-arm: CFLAGS +=3D -marm -I$(SRC_PATH)/tests/tcg/$(TARGET_NAME) semihosting-arm: semihosting.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) =20 run-semihosting-arm: semihosting-arm $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") =20 -run-plugin-semihosting-with-%: +run-plugin-semihosting-arm-with-%: $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \ $(call strip-plugin,$<) 2> $<.err, \ "$< on $(TARGET_NAME) with $*") =20 -ARM_TESTS +=3D semiconsole semiconsole-arm +ARM_TESTS +=3D semiconsole-arm =20 semiconsole: CFLAGS +=3D -mthumb -run-semiconsole: semiconsole - $(call skip-test, $<, "MANUAL ONLY") =20 -run-plugin-semiconsole-with-%: - $(call skip-test, $<, "MANUAL ONLY") - -semiconsole-arm: CFLAGS +=3D -marm -semiconsole-arm: semiconsole.c +semiconsole-arm: CFLAGS +=3D -marm -I$(SRC_PATH)/tests/tcg/$(TARGET_NAME) +semiconsole-arm: semihosting.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) =20 run-semiconsole-arm: semiconsole-arm @@ -68,6 +62,8 @@ run-semiconsole-arm: semiconsole-arm run-plugin-semiconsole-arm-with-%: $(call skip-test, $<, "MANUAL ONLY") =20 +endif + ARM_TESTS +=3D commpage =20 TESTS +=3D $(ARM_TESTS) diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Make= file.target index abbdb2e126..a3a751723d 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -69,6 +69,37 @@ run-gdbstub-%: endif EXTRA_RUNS +=3D run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read =20 +# ARM Compatible Semi Hosting Tests +# +# Despite having ARM in the name we actually have several +# architectures that implement it. We gate the tests on the feature +# appearing in config. +# +ifeq ($(CONFIG_ARM_COMPATIBLE_SEMIHOSTING),y) +VPATH +=3D $(MULTIARCH_SRC)/arm-compat-semi + +# Add -I path back to TARGET_NAME for semicall.h +semihosting: CFLAGS+=3D-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME) + +run-semihosting: semihosting + $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") + +run-plugin-semihosting-with-%: + $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ + -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \ + $(call strip-plugin,$<) 2> $<.err, \ + "$< on $(TARGET_NAME) with $*") + +semiconsole: CFLAGS+=3D-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME) + +run-semiconsole: semiconsole + $(call skip-test, $<, "MANUAL ONLY") + +run-plugin-semiconsole-with-%: + $(call skip-test, $<, "MANUAL ONLY") + +TESTS +=3D semihosting semiconsole +endif =20 # Update TESTS TESTS +=3D $(MULTIARCH_TESTS) --=20 2.20.1 From nobody Wed Apr 24 05:32:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616248137; cv=none; d=zohomail.com; s=zohoarc; b=MYWA1TLA3G4ulHi3mbVSfb+6PAKa/bYz37pBxW3kZQYNNLPfihhJsGR7EEUZRrbgWbNGnxBT7xyDgihkFilymk+eayp/mz8gBWgyR3rW0isBjwWmu2VOBmVplG/6klqSUfcjT0431ZIn1U1/HbaEPkWELqfMkWa0e3mf5AYT2n0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616248137; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rLEsx07yxF/Bt1JL1Eo30fED3vfHhKy7OHokAU6q/Nw=; b=ieJ8pE22RbFfm/Hmn6/T3qK/i1/8KqYxPl8jlca9vwNftAB4jOyTviczfOMXgw4H+FF+X04LrXKMhwjhfpb6grzaLQ9qLimatu4HLIQEebaNNnmyyMi7Y1c7jTHRjoBigzN/ZLw2v3T0KeNrwO0ObkuW/y4m10ib9n5C1dFR8t8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161624813786299.58789927176144; Sat, 20 Mar 2021 06:48:57 -0700 (PDT) Received: from localhost ([::1]:45202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbyK-0006Po-Qx for importer@patchew.org; Sat, 20 Mar 2021 09:48:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNbn8-000384-2g for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:22 -0400 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]:41551) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNbn6-0004HV-7O for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:21 -0400 Received: by mail-ej1-x62c.google.com with SMTP id u5so14058289ejn.8 for ; Sat, 20 Mar 2021 06:37:19 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id h13sm6170051edz.71.2021.03.20.06.37.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:37:10 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 543691FF92; Sat, 20 Mar 2021 13:37:07 +0000 (GMT) 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=rLEsx07yxF/Bt1JL1Eo30fED3vfHhKy7OHokAU6q/Nw=; b=N8/2UfstRKqeXxkOf5npk+yhbHNfAqYeLA9j7nelQyyJ46/dBggkL5ge6ZnTTlrMsk l8JqJ3bOWphrsWHFFIwE9jmvHKkdwBFM+gbiGabEJVkIbq6Zadcu8KPwfNDWdny44h5+ 0nLPpfqwpFraN+c8mXuEjXagDQ5HBv4JUJt92HMVq86OWg5vZoAsazUD+7hke1UqtKlE yBVJJ9dlZRgJ1ktctRtskvUiRhXcfoYvs6bou2ARR0x2LKFaarf18KS/4puPk2CHPcWD BcRGIIlK98bIegC/qXx6J5WEn/HTEO29NioB+wNonp5SwTM7GfMT/XqeFg1nUNYnuJMw OFmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rLEsx07yxF/Bt1JL1Eo30fED3vfHhKy7OHokAU6q/Nw=; b=jt4Hb6/Ymw+edcbPtAnq1P6xfcNcpN91m49w5nQfPaMQpdn6DGvUpaoNbh16gPCJIM SFDB//Fr5JDynoGw4i2Tfe/2SD//mGqhw3wVtAQ0moD76iBvQptG0fkW0U3eNtBhi4uq 38IlBHqZWdwMAPsqGM7Y4qMUVEypdj9FkInzUsXVEvmKDjAKUTajr4auTGhoUWUHx0hk 2AuOA/+IwaumFPDhGK7q0epw1sJ88IfycX2FGS/YExu5dBnFXKXttg+MOZo/6fCPblDH ttsrhFtR4cQ74eNJ+FiA/5Iah8NNozF7lXhV8VwjeQaLrNUrjRM7NVkSBgkHSmUyyS7r vgpg== X-Gm-Message-State: AOAM5319xN1p5/LyBCTDaQGVD8+piD+5rjLf4pK+zmnxiOGpN9JIjkd7 J+DENDq+mrt4UJ61Rl/WNSIebw== X-Google-Smtp-Source: ABdhPJxXHFRvfhdUOhy/gMo451pTUIWNKBsrKGdvfUcgoERowkWG7Yw5pf0ShmCI4rII2kK/9CGhsw== X-Received: by 2002:a17:907:162b:: with SMTP id hb43mr9855705ejc.41.1616247438881; Sat, 20 Mar 2021 06:37:18 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 06/14] semihosting/arm-compat-semi: unify GET/SET_ARG helpers Date: Sat, 20 Mar 2021 13:36:58 +0000 Message-Id: <20210320133706.21475-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210320133706.21475-1-alex.bennee@linaro.org> References: <20210320133706.21475-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62c; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62c.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Keith Packard , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) >From the semihosting point of view what we want to know is the current mode of the processor. Unify this into a single helper and allow us to use the same GET/SET_ARG helpers for the rest of the code. Having the helper will also be useful later. Note: we aren't currently testing riscv32 due to missing toolchain for check-tcg tests. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Reviewed-by: Keith Packard Message-Id: <20210312102029.17017-3-alex.bennee@linaro.org> --- semihosting/arm-compat-semi.c | 56 ++++++++++++----------------------- 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 94950b6c56..0f0e129a7c 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -767,15 +767,28 @@ static const GuestFDFunctions guestfd_fns[] =3D { }, }; =20 -/* Read the input value from the argument block; fail the semihosting - * call if the memory read fails. +/* + * Read the input value from the argument block; fail the semihosting + * call if the memory read fails. Eventually we could use a generic + * CPUState helper function here. */ -#ifdef TARGET_ARM +static inline bool is_64bit_semihosting(CPUArchState *env) +{ +#if defined(TARGET_ARM) + return is_a64(env); +#elif defined(TARGET_RISCV) + return !riscv_cpu_is_32bit(env); +#else +#error un-handled architecture +#endif +} + + #define GET_ARG(n) do { \ - if (is_a64(env)) { \ + if (is_64bit_semihosting(env)) { \ if (get_user_u64(arg ## n, args + (n) * 8)) { \ errno =3D EFAULT; \ - return set_swi_errno(cs, -1); \ + return set_swi_errno(cs, -1); \ } \ } else { \ if (get_user_u32(arg ## n, args + (n) * 4)) { \ @@ -786,41 +799,10 @@ static const GuestFDFunctions guestfd_fns[] =3D { } while (0) =20 #define SET_ARG(n, val) \ - (is_a64(env) ? \ + (is_64bit_semihosting(env) ? \ put_user_u64(val, args + (n) * 8) : \ put_user_u32(val, args + (n) * 4)) -#endif =20 -#ifdef TARGET_RISCV - -/* - * get_user_ual is defined as get_user_u32 in softmmu-semi.h, - * we need a macro that fetches a target_ulong - */ -#define get_user_utl(arg, p) \ - ((sizeof(target_ulong) =3D=3D 8) ? \ - get_user_u64(arg, p) : \ - get_user_u32(arg, p)) - -/* - * put_user_ual is defined as put_user_u32 in softmmu-semi.h, - * we need a macro that stores a target_ulong - */ -#define put_user_utl(arg, p) \ - ((sizeof(target_ulong) =3D=3D 8) ? \ - put_user_u64(arg, p) : \ - put_user_u32(arg, p)) - -#define GET_ARG(n) do { \ - if (get_user_utl(arg ## n, args + (n) * sizeof(target_ulong))) { \ - errno =3D EFAULT; \ - return set_swi_errno(cs, -1); \ - } \ - } while (0) - -#define SET_ARG(n, val) \ - put_user_utl(val, args + (n) * sizeof(target_ulong)) -#endif =20 /* * Do a semihosting call. --=20 2.20.1 From nobody Wed Apr 24 05:32:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616247744; cv=none; d=zohomail.com; s=zohoarc; b=jEdlk8CtOhcsuq0f6aMtqw+j0XaZzLVKKVrxB3Xj+hRsgQOwLerBG/zeh0IaDkTZE2vNf8d/47/AB4LJgLAYPMs4GEASkuK+OhwFDPCFRf5puVaaHl/OIsE9OmpPoqzUuvs6mivcIJeXBIvUgztLjb+Tg4CRiUreTMNxuLxpRW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616247744; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=H/e/SdGSFzWo+xbjndfr99fhe97V2yal8vW6qxaRucA=; b=CtBO9CGq3ECyU0bDKlzIvsiMS/FoERmhMXjUHT6y6Lu5xqTK441EY5dgfMyrm7C7q9mCVgeEyE38LGVzM1Ryf50fBg8K3prV80FrWZjAWEh6Px2yfwnNasiKm4x8w+bds7b8kfFGsInmAYjWE6CB6hrFnV7tm5I5IwNNDXL8PIk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616247744431638.6151601927256; Sat, 20 Mar 2021 06:42:24 -0700 (PDT) Received: from localhost ([::1]:57764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbrz-0008FH-4A for importer@patchew.org; Sat, 20 Mar 2021 09:42:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNbn6-00034M-C9 for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:20 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]:46024) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNbn4-0004Gm-Ji for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:20 -0400 Received: by mail-ej1-x62b.google.com with SMTP id kt15so4581703ejb.12 for ; Sat, 20 Mar 2021 06:37:18 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c17sm6773579edw.32.2021.03.20.06.37.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:37:10 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6A8211FF93; Sat, 20 Mar 2021 13:37:07 +0000 (GMT) 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=H/e/SdGSFzWo+xbjndfr99fhe97V2yal8vW6qxaRucA=; b=pbpHF2NtDcnU+gVku79AOo669AZh4wmkmNpTzMX+L8Jk4sxlIU3a/2FIuAzU+4Emi2 P0D5isRSDzlP7X1UMxfZdnVivGloRNVegRzeH+mUOozo+f7xhkj87Mr7V6BIW/2Q6eSR qDZJ0HUEkSgO20/16YL4hYe4kfNLqSB6xRWr784e+FLlHehtAnpDYMbu9SojZH2Vpkzi 2aRmBmnVWpSqdYBVwjX48XYu2d+KegtDAr3hjw2wBRHfXe2tKLzVIi6H+UuVYtcOq/Nh blW2uo5DRohmuZaSA2eQh8jTDOvkmlfbNVbQbsL0LOXJ03FHWW3VkAyExDGZTqCrw6EH yYUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H/e/SdGSFzWo+xbjndfr99fhe97V2yal8vW6qxaRucA=; b=ew1cXW/wXaEC3YoMiP1GbWhlM9vkP9fysZzzYEhEHsaPuJubfYMiMd43P7+cFlijNn cxdOEyDCNUXGN+BAuvCiSMfW900r1t+vt4T3muLiVroRpsJzmaUo4nL6rKiOdmfC/q1x Iz1/Oeh0BfHYeDwpT6NztoycMbuggJaEIeeJO8PK34dNrlEYNAmmz1h3TVZNUMpqISDv GDyzy7FZHG7YivvreWTdT6p510AAv5CrJJlfjeXmY5vq8wfAfxs5Ze6+Gy5RJUCWumys jZ3mPfck60xgmTBbfRTmYAxBwFhKr3RWglnWelMHsmagIioe3kwfjbEPghixi8PmtS8T M5JQ== X-Gm-Message-State: AOAM5328HeXOtKNjpgoNtlhFqVq1O0vFeFAbs+huTDwVaLfizkhhlx91 0GMxKIIyfbbSjp6wvK8xL5H7eogTXEUzk+s+ X-Google-Smtp-Source: ABdhPJw1lWpV6Exj5U/l1R0WdZlA5ZAFROJXQkCBd2WdiX4rvTiSHpmJmWru5shOtMb6iH/BJsVbRA== X-Received: by 2002:a17:906:d554:: with SMTP id cr20mr9859829ejc.61.1616247437251; Sat, 20 Mar 2021 06:37:17 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 07/14] semihosting/arm-compat-semi: don't use SET_ARG to report SYS_HEAPINFO Date: Sat, 20 Mar 2021 13:36:59 +0000 Message-Id: <20210320133706.21475-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210320133706.21475-1-alex.bennee@linaro.org> References: <20210320133706.21475-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62b.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Keith Packard , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Bug 1915925 <1915925@bugs.launchpad.net> Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) As per the spec: the PARAMETER REGISTER contains the address of a pointer to a four-field data block. So we need to follow arg0 and place the results of SYS_HEAPINFO there. Fixes: 3c37cfe0b1 ("semihosting: Change internal common-semi interfaces to = use CPUState *") Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Cc: Bug 1915925 <1915925@bugs.launchpad.net> Cc: Keith Packard Bug: https://bugs.launchpad.net/bugs/1915925 Message-Id: <20210312102029.17017-4-alex.bennee@linaro.org> --- semihosting/arm-compat-semi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 0f0e129a7c..fe079ca93a 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -1214,7 +1214,11 @@ target_ulong do_common_semihosting(CPUState *cs) for (i =3D 0; i < ARRAY_SIZE(retvals); i++) { bool fail; =20 - fail =3D SET_ARG(i, retvals[i]); + if (is_64bit_semihosting(env)) { + fail =3D put_user_u64(retvals[i], arg0 + i * 8); + } else { + fail =3D put_user_u32(retvals[i], arg0 + i * 4); + } =20 if (fail) { /* Couldn't write back to argument block */ --=20 2.20.1 From nobody Wed Apr 24 05:32:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616247907; cv=none; d=zohomail.com; s=zohoarc; b=hKZnrs9OlkV0TDqWghP7xkF7ynzj7uwLzpV6NjLYjoHhxUCvu70gvPgAqZf8WSzL1uHSRiyE9VfxyRTuQKTM24Z1c6fgvEu8wzHViqpCZ5chcjEC9+1ZxcYjlpkZfS2eqhv6pLNo9HuORsZ6svd0jnUWyr+mALTf5jVS5pS1Bi8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616247907; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lOTtqQ1GqfCDk2mShrLCLuCwUnyYqPWN4bH2H+UmRI8=; b=RkhqVgA5eoyGcaNFIBIgZ/gh6Xbn0Sx2iD/YofsPnN6ruEl2aw/7bPbPVIlWb+j6VllyTjuokq0lJBrkhgq4ehZO5nMYWDXWS/Sp+lM38oqyXWOv8ZgLewqPRaQIx61E9s2NyRQ60I1ry5iFyQliK45sbTlaW6jyWth/PeZ5O3s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616247907410935.4891170543608; Sat, 20 Mar 2021 06:45:07 -0700 (PDT) Received: from localhost ([::1]:36450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbua-0002gQ-1h for importer@patchew.org; Sat, 20 Mar 2021 09:45:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNbn5-00032X-B0 for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:19 -0400 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]:38634) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNbn3-0004Fo-QF for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:19 -0400 Received: by mail-ed1-x52c.google.com with SMTP id h13so14028062eds.5 for ; Sat, 20 Mar 2021 06:37:17 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id oy8sm5346287ejb.58.2021.03.20.06.37.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:37:10 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 80D0F1FF96; Sat, 20 Mar 2021 13:37:07 +0000 (GMT) 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=lOTtqQ1GqfCDk2mShrLCLuCwUnyYqPWN4bH2H+UmRI8=; b=d6aEufXYSJved5N2un3csV6hO7nw6dV7AH6C5EsjQil81UStphfQfJY4gQ86HYO87J qnB4XmhBD+vVFGC4si866ae8tuqh6Xs0MoZVrwB+HTi+XRN4vIhGQLOoNri5uLSdASJ4 P2KphUGWsg9uWIe5EFJ8A/KZEcDCwJz8CPoxIn/tb4L5vOXC24l4o1qvTDL3DdBmcSZc UVnUr7EV/gBxGRgRaVHFOfnW1AYJv+p2VgIpWCsQA6eiD3+FGq4En2yKwKloozotH2j8 me6Edv6htK6kyScGym8jcmDaOvBrfoFgfMIWI5V6BIcdd9SqMf+RU8VIJuglwbQwYf9o jXwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lOTtqQ1GqfCDk2mShrLCLuCwUnyYqPWN4bH2H+UmRI8=; b=ZNHEzM+Vwlrfsd86lo7233vcG1tSDaIfJSqk7bA8AF8wCYvJ8vMqxBd2yaWff5YQqX Y7KlaryXxoPoC9/16O1wYff2RuMqaPJVI8oE+TPeCR//yrNxsWQO3DsNswT8r+ZgLVHi rYIL5DrvzB55XeJKX4F53FHZ1Q84NvF4uZbZ43J6o5Ql1pwnVjOE+plJA6M6sLXNNc8a epzSYRip+lp3II7FyGPzVyq3NN117ZV/8/OZSyyQLjR/QO2vfszjU9AlfHWyG1scfSca bw/0RJD5WUBYb6PnHpuVkaJTdAEBPTHz3pHRxuNeaVajgotP2/AIOoP7/Si8j/5HpKZt RK+Q== X-Gm-Message-State: AOAM533qr8TDL0U7V+/qhtVohVHxNG+p/O5I18i3F50SjNxqZUc9blxk NEisqro5atOHx1dpVIMLvPdcZA== X-Google-Smtp-Source: ABdhPJxt29BP8t5HbS4l1O0iZHbkQuXrDClFGYTwR0duK0TMe7/+NixB7qhv2aMD9JRSk+xz9Wq3mw== X-Received: by 2002:a05:6402:614:: with SMTP id n20mr15344467edv.58.1616247436513; Sat, 20 Mar 2021 06:37:16 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 08/14] linux-user/riscv: initialise the TaskState heap/stack info Date: Sat, 20 Mar 2021 13:37:00 +0000 Message-Id: <20210320133706.21475-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210320133706.21475-1-alex.bennee@linaro.org> References: <20210320133706.21475-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52c.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Arguably the target_cpu_copy_regs function for each architecture is misnamed as a number of the architectures also take the opportunity to fill out the TaskState structure. This could arguably be factored out into common code but that would require a wider audit of the architectures. For now just replicate for riscv so we can correctly report semihosting information for SYS_HEAPINFO. Signed-off-by: Alex Benn=C3=A9e Message-Id: <20210312102029.17017-5-alex.bennee@linaro.org> Reviewed-by: Richard Henderson --- linux-user/riscv/cpu_loop.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c index 6767f941e8..74a9628dc9 100644 --- a/linux-user/riscv/cpu_loop.c +++ b/linux-user/riscv/cpu_loop.c @@ -135,4 +135,9 @@ void target_cpu_copy_regs(CPUArchState *env, struct tar= get_pt_regs *regs) error_report("Incompatible ELF: RVE cpu requires RVE ABI binary"); exit(EXIT_FAILURE); } + + ts->stack_base =3D info->start_stack; + ts->heap_base =3D info->brk; + /* This will be filled in on the first SYS_HEAPINFO call. */ + ts->heap_limit =3D 0; } --=20 2.20.1 From nobody Wed Apr 24 05:32:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616248257; cv=none; d=zohomail.com; s=zohoarc; b=A2zWaG2nTQABO5KEOkWSmAXqMhGi/0HXsjcCSoiNN32I0TUNMZH+6o8jKcaGJ8RGiv9hGIhioCSz9TA6TpJKp4iK2ST7edTgchhn75tA8lMqiqiTPyNlJEWKIwMI5IMsMiUhgdGOyd74H3DJUeqTIDjmezE4FN+7MxpjoDN+JCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616248257; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Pa/Fiua7g7Vmj4OKm8oDu8MB1fXTUZdi8REKYNbvuPI=; b=KORM5u1al9adSTe3LbFIC1x65z2Zdwxa5dsg8LdSEo4WToDkJ8tSZ6DqwQngWgOCpprushws2T0fsfo3HfeJcvXU4SvZx9M8YfMqMnaAAcX1GxzWA44T5k7mw6NYCHFuuX//Lhu9S77TY5prciL90q7qCalJnC46JeAPgPONazU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616248257514116.23253658940189; Sat, 20 Mar 2021 06:50:57 -0700 (PDT) Received: from localhost ([::1]:50664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNc0G-0000Nb-Dj for importer@patchew.org; Sat, 20 Mar 2021 09:50:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNbnF-00039h-Gz for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:29 -0400 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]:37403) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNbn7-0004Ix-VA for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:29 -0400 Received: by mail-ej1-x62e.google.com with SMTP id w3so14057533ejc.4 for ; Sat, 20 Mar 2021 06:37:21 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z9sm6395566edr.75.2021.03.20.06.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:37:18 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 977571FF98; Sat, 20 Mar 2021 13:37:07 +0000 (GMT) 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=Pa/Fiua7g7Vmj4OKm8oDu8MB1fXTUZdi8REKYNbvuPI=; b=XMtuW8cHBV5cUVfEQJ/Wly7KUz6KaMk92eQL5pojG+/oC+DyjkSUWlwrRtNqjtg4Vu PlXkecM6Zb1VtLOxsfMPyuip6YctedVP9dlRjILlwqztMaxRCRutRrqKWVVAnQ/b1EwY lCLRXfdTfz4h/GN1ePLrNrI/PcUrMkzjh3GG0lc2UoO7K3woBPe43ULo49c+Vyg1Bd6Z cKkUvfkXsSFgNUmHk/7B1DKZU+TP8KpDF5uD2lCzEFtDkbwKbI+MipVxa2oWy14CmebV oFBpdwnV8KWq+1uJi9Cy5txOKs2XBWKkxjXi4R9HQC80GwTM2zcmRZQECHtdX9HH8kxA WbLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Pa/Fiua7g7Vmj4OKm8oDu8MB1fXTUZdi8REKYNbvuPI=; b=ipwyDMjPzaVgy5u1YCqN/FLJU+esIKmN9TqE1r9xlXc2Uj96CxZ2CZ+rKBI/qBiXuE JleOFfpVV5HQmvmXP1hkY+hwlLBUXTCEF6PhjHgx4mQIxUtRSUGx+GjBIuDP67uq0irw ygyTPQE9dl0cdcT9TV7+G0Fu+lPYNo2t8Zh8xjzF9gIB+EgmOzH+Je+EmOr548mQQVBm uuRxObDS2RUFN9QRTN8XRArDo62Svr7Y1k7oquaRW9/fTip6W9IiWGhEgXioi6cbryBf SzBCji2Bj4YqOkWPhXbPy3+YjhAFfpC46NlWrTzDjDeXRo48AQ8W+FPc3spkDfS+oj00 BLTw== X-Gm-Message-State: AOAM531wMXz+szdbtHzHhO/En+wCOG9/NaNJ20CEzgsgSNbMQM0BUAkL 26nnqqHDwx40q+2KkUxTGVuPQqRnUgwCv35L X-Google-Smtp-Source: ABdhPJxRmkc2IAjoLIoMMiJI7MfVBKdOyPCw8lhswACsyXUWl6waTS/fINjJ9TWwlwnjq9/kVXaXAA== X-Received: by 2002:a17:906:1c98:: with SMTP id g24mr9843221ejh.51.1616247440703; Sat, 20 Mar 2021 06:37:20 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 09/14] tests/tcg: add HeapInfo checking to semihosting test Date: Sat, 20 Mar 2021 13:37:01 +0000 Message-Id: <20210320133706.21475-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210320133706.21475-1-alex.bennee@linaro.org> References: <20210320133706.21475-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62e.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Query the SYS_HEAPINFO semicall and do some basic verification of the information via libc calls. Signed-off-by: Alex Benn=C3=A9e Message-Id: <20210312102029.17017-6-alex.bennee@linaro.org> --- .../multiarch/arm-compat-semi/semihosting.c | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/tests/tcg/multiarch/arm-compat-semi/semihosting.c b/tests/tcg/= multiarch/arm-compat-semi/semihosting.c index b3fd16cd12..8e9cfb578c 100644 --- a/tests/tcg/multiarch/arm-compat-semi/semihosting.c +++ b/tests/tcg/multiarch/arm-compat-semi/semihosting.c @@ -8,9 +8,13 @@ */ =20 #define SYS_WRITE0 0x04 +#define SYS_HEAPINFO 0x16 #define SYS_REPORTEXC 0x18 =20 #include +#include +#include +#include #include "semicall.h" =20 int main(int argc, char *argv[argc]) @@ -21,8 +25,46 @@ int main(int argc, char *argv[argc]) uintptr_t exit_block[2] =3D {0x20026, 0}; uintptr_t exit_code =3D (uintptr_t) &exit_block; #endif + struct { + void *heap_base; + void *heap_limit; + void *stack_base; + void *stack_limit; + } info; + void *ptr_to_info =3D (void *) &info; =20 - __semi_call(SYS_WRITE0, (uintptr_t) "Hello World"); + __semi_call(SYS_WRITE0, (uintptr_t) "Checking HeapInfo\n"); + + memset(&info, 0, sizeof(info)); + __semi_call(SYS_HEAPINFO, (uintptr_t) &ptr_to_info); + + if (info.heap_base =3D=3D NULL || info.heap_limit =3D=3D NULL) { + printf("null heap: %p -> %p\n", info.heap_base, info.heap_limit); + exit(1); + } else if (info.heap_base !=3D NULL && info.heap_limit !=3D NULL) { + /* Error if heap base is above limit */ + if ((uintptr_t) info.heap_base >=3D (uintptr_t) info.heap_limit) { + printf("heap base %p >=3D heap_limit %p\n", + info.heap_base, info.heap_limit); + exit(2); + } + } + + if (info.stack_base =3D=3D NULL) { + printf("null stack: %p -> %p\n", info.stack_base, info.stack_limit= ); + exit(3); + } else if (info.stack_base !=3D NULL && info.stack_limit !=3D NULL) { + /* Error if stack base is below limit */ + if ((uintptr_t) info.stack_base < (uintptr_t) info.stack_limit) { + printf("stack base %p < stack_limit %p\n", + info.stack_base, info.stack_limit); + exit(4); + } + } + printf("heap: %p -> %p\n", info.heap_base, info.heap_limit); + printf("stack: %p -> %p\n", info.stack_base, info.stack_limit); + + __semi_call(SYS_WRITE0, (uintptr_t) "Passed HeapInfo checks"); __semi_call(SYS_REPORTEXC, exit_code); /* if we get here we failed */ return -1; --=20 2.20.1 From nobody Wed Apr 24 05:32:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616247748; cv=none; d=zohomail.com; s=zohoarc; b=Fiz4S+sytZ0B88O5pdIKiadHUxfPDqC+x0yEEE3z60lRt0c4oKpBU/EFB5DqlzERrLi8Zt7eS+UB4MsV89vnS+kuBts2Wup5wzpWAumhN6UKbbdzYHOm42znVLZFkBDVzr8qwdyQIzHY8YIj5UlCnvQupxGwx2pUv3JTfese/CE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616247748; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GabEOI8qt2VYTbFRWHqczSknP0jlmCGZSofoXChZAOc=; b=dC/8sRkObBd22JKhVxsv8mDGEEAhW5b6bnRwpIghRhbOQuOkSdyTaBXRUc8KZQkzHWvZiLWKcglnT7XrMQwnbgbhIGtmRwurorsZkTCRb07JCDZUiCfnPKVL6jKWU2WhnOW/J7EfkqZDWYfPCIu/Rz4QcDDsVMGqo2m6jWsKy1I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616247748856666.9557371855469; Sat, 20 Mar 2021 06:42:28 -0700 (PDT) Received: from localhost ([::1]:57818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbs3-0008GU-Gw for importer@patchew.org; Sat, 20 Mar 2021 09:42:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNbnI-0003Cf-Ez for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:34 -0400 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]:46794) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNbnC-0004Jp-HA for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:32 -0400 Received: by mail-ej1-x62a.google.com with SMTP id t18so14031952ejc.13 for ; Sat, 20 Mar 2021 06:37:25 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id lk12sm5311014ejb.14.2021.03.20.06.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:37:18 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AD7741FF99; Sat, 20 Mar 2021 13:37:07 +0000 (GMT) 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=GabEOI8qt2VYTbFRWHqczSknP0jlmCGZSofoXChZAOc=; b=vTSOM5/ga2T/vUz15TYvcWOAcva2vI0SIv5D6+yB7BrggkQRGPHbJc2yrTby1SqVd5 +zfzIbRK1cc/TMYLf5lMdSBl9d6X4dejfJlye5jWQLeiJInq5XMjHqlGR/VkBV7gKEmR wi7fuMTyp87DeAd6hcRVSDuKDmqNAzJhymavWDe5fl/4MKMBawCNVfA51k3XKRNwVEig 8ttGmAHeDFea+bW4Azt8O5Bv9AXw2hVHbow8NnbuyebvrQq3xtmIP+cXsvin9sZfuubm SQjmVF1gUgRe20GMVPX8DhT/fhzpIHDeIyJN2rURAI8xmJXI9/p3p0Cl4lW17cXQ6kPQ 6CnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GabEOI8qt2VYTbFRWHqczSknP0jlmCGZSofoXChZAOc=; b=HedzoPYpDR5C/PGAEvG5UT0v/G9jCJvQxl1ByVorqTIlpMMHwoCOARG0ahvDk3L4hW 0XiY+HI/ljuiEOkpXETf+FWhMYt3fAQD3N6Wwza97J9MtUa2vXPBuhXVRbbvFVOhZvYO rrjkhzwxqZz6Annut1qMq7BnGwBOHSXb+ezKZ31FY9t2xqsmhzLed91ne9HY0B4QPnjX WfSmwHQPb0gFrJzCBVRb5PKx9Xf1I/9R2x+c+b6/tMu/gliUYKx37Fd/b2EDImXeiBoZ 4Dej3b7FgxliCRCQ2Vzpqb8dAWDGdA8bk0EFJQsdNGB4zjQE2BC72Vosod9Zk6RIEIB6 FoFQ== X-Gm-Message-State: AOAM533WQoCSFZ6NQ7WQZlblEsEf2QBOmx+MJm/DvJpv/ELjq7tvwbXa cQQHirow3fUqasa5ekq0MGo1zA== X-Google-Smtp-Source: ABdhPJwxSoMs7mQ+hzXzzCLWKmDDL7bifCwselag3ti1ulr+3FsU0VEeEZKlH4qK1gmFgjo+F5TamA== X-Received: by 2002:a17:906:4747:: with SMTP id j7mr9634327ejs.221.1616247444264; Sat, 20 Mar 2021 06:37:24 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 10/14] gitlab-ci.yml: Merge the trace-backend testing into other jobs Date: Sat, 20 Mar 2021 13:37:02 +0000 Message-Id: <20210320133706.21475-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210320133706.21475-1-alex.bennee@linaro.org> References: <20210320133706.21475-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Willian Rampazzo , Thomas Huth , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Thomas Huth Our gitlab-ci got quite slow in the past weeks, due to the immense amount of jobs that we have, so we should try to reduce the number of jobs. There is no real good reason for having separate jobs just to test the trace backends, we can do this just fine in other jobs, too. Signed-off-by: Thomas Huth Message-Id: <20210319095726.45965-1-thuth@redhat.com> Reviewed-by: Wainer dos Santos Moschetta Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Willian Rampazzo --- .gitlab-ci.yml | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f65cb11c4d..f746d5fbea 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -87,7 +87,7 @@ build-system-alpine: TARGETS: aarch64-softmmu alpha-softmmu cris-softmmu hppa-softmmu moxie-softmmu microblazeel-softmmu mips64el-softmmu MAKE_CHECK_ARGS: check-build - CONFIGURE_ARGS: --enable-docs + CONFIGURE_ARGS: --enable-docs --enable-trace-backends=3Dlog,simple,sys= log artifacts: expire_in: 2 days paths: @@ -605,7 +605,7 @@ tsan-build: variables: IMAGE: ubuntu2004 CONFIGURE_ARGS: --enable-tsan --cc=3Dclang-10 --cxx=3Dclang++-10 --dis= able-docs - --enable-fdt=3Dsystem --enable-slirp=3Dsystem + --enable-trace-backends=3Dust --enable-fdt=3Dsystem --enable-sli= rp=3Dsystem TARGETS: x86_64-softmmu ppc64-softmmu riscv64-softmmu x86_64-linux-user MAKE_CHECK_ARGS: bench V=3D1 =20 @@ -702,6 +702,7 @@ build-coroutine-sigaltstack: variables: IMAGE: ubuntu2004 CONFIGURE_ARGS: --with-coroutine=3Dsigaltstack --disable-tcg + --enable-trace-backends=3Dftrace MAKE_CHECK_ARGS: check-unit =20 # Most jobs test latest gcrypt or nettle builds @@ -739,31 +740,6 @@ crypto-only-gnutls: MAKE_CHECK_ARGS: check =20 =20 -# We don't need to exercise every backend with every front-end -build-trace-multi-user: - <<: *native_build_job_definition - needs: - job: amd64-ubuntu2004-container - variables: - IMAGE: ubuntu2004 - CONFIGURE_ARGS: --enable-trace-backends=3Dlog,simple,syslog --disable-= system - -build-trace-ftrace-system: - <<: *native_build_job_definition - needs: - job: amd64-ubuntu2004-container - variables: - IMAGE: ubuntu2004 - CONFIGURE_ARGS: --enable-trace-backends=3Dftrace --target-list=3Dx86_6= 4-softmmu - -build-trace-ust-system: - <<: *native_build_job_definition - needs: - job: amd64-ubuntu2004-container - variables: - IMAGE: ubuntu2004 - CONFIGURE_ARGS: --enable-trace-backends=3Dust --target-list=3Dx86_64-s= oftmmu - # Check our reduced build configurations build-without-default-devices: <<: *native_build_job_definition --=20 2.20.1 From nobody Wed Apr 24 05:32:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616248123; cv=none; d=zohomail.com; s=zohoarc; b=kU7vDZGl6V4YjaPyzGJWUfLtIjaa9Pe2XAbELLHoZ9Mdz555ykIH0uTiuYBGychST7w1L2sUNdQXR3jU+NkH2STVMXKkAMcdQl534LGHAl50U2U5y92IpGwVd3NkXurL4MiPduy3ZTbQa9tgX3UB3ceEIoBiz7feOAP6+JRkbRo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616248123; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xDQfMQ2++LPf2hEK5W0FEnogdPCtNwE5cK792H3OCyE=; b=fkiuTcDS+Ma/fSZmt7M+lTfpszmz9f39DPTohjYnh6eIukkVHA7g87fNej5bi+qgg3f79WoVMQYJAX612+03fak2YPQjyIflOvUGMmDl30U15P5nUXn2fJAT/5wCOD/EPro362TrrK4vJum00WcQypjN1fMyzKOzrQxqPo9sVcI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616248123825305.19292736928276; Sat, 20 Mar 2021 06:48:43 -0700 (PDT) Received: from localhost ([::1]:43984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNby6-0005tS-80 for importer@patchew.org; Sat, 20 Mar 2021 09:48:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNbnG-0003CD-JF for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:32 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:45596) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNbnC-0004J7-Gk for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:30 -0400 Received: by mail-ed1-x535.google.com with SMTP id bx7so14013450edb.12 for ; Sat, 20 Mar 2021 06:37:22 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id lx6sm5359387ejb.64.2021.03.20.06.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:37:18 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C38401FF9A; Sat, 20 Mar 2021 13:37:07 +0000 (GMT) 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=xDQfMQ2++LPf2hEK5W0FEnogdPCtNwE5cK792H3OCyE=; b=v8a6cZu447FTG2LFvEhb+HrBBConQem4MaGj0GgfuHv8Uxbcl6IpEMUfyvFjsyDS72 kgrQw2yPa+fUwvaj9qeG2E/xDzluypj9YekHRwsEyJjtd1ibZ6vzkFLzQ1C0i5DbPJLw Pru4SV94M5oVfJtLKLUEkWsFYxFiY4fu/pO3oeZHsHYJcyqoNF2smD4zEf/XoZCzPt11 rk65FvyknFftieehIb2jGskySYZ1aDYSMNEiM7MkED22cHi4AEfI4WklIecgFdz9NJmn wizXUSxNHBQKvypepDWVen++iBM+BRJwEzqUvNhMGs+9DC5qPoGAyWJrMSQLPD+uQwc8 cw6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xDQfMQ2++LPf2hEK5W0FEnogdPCtNwE5cK792H3OCyE=; b=Mbh0uHUyWXcHP2orFrFmdi/OXikCCWR6He7EGFPKnSHzkIGUuob5r6Ac1XbwHJG2+Y yEUpqNvhmaBvRp+9/TJ6KrfamaLvtrbLP0yHvOSIP/CiaOX4A/ADqeeW3pRMTW9Nqy8e EMADutIzaUn0tWEUBMzQ8d/rtnMcBQV5NRVzhtoq6HbbakLF2sYjjHHmw/VrUu/CYjT9 nf9qi9DCdORwkr7uyQ8a/x4ts8g+U/uYvUZV/z1zIZbaiz+vCJPArNK+J1ZAONfrKFbi lRL1vqM4LEY3xf0ADPJs4gGQLdT8XVP7pmE5vTUPdtQqRO6nBuo8eBnbg9P49USv5VGB n2ig== X-Gm-Message-State: AOAM531cZOhy0Q9gphS49OoYcdug/yQqHOtm/7cNeOFsUpq471ydkjUK WczyGpRijZ+hkz1qB1wiozHBP0T4JBdrQZWH X-Google-Smtp-Source: ABdhPJwruwQ+9jLq0xS+GnlTBVLP568vCKT2IK6kuyvjHy+tx8thf+tHy7+eaduldfqmfgbV9/hrNQ== X-Received: by 2002:a05:6402:84b:: with SMTP id b11mr15281895edz.56.1616247441692; Sat, 20 Mar 2021 06:37:21 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 11/14] configure: Don't use the __atomic_*_16 functions for testing 128-bit support Date: Sat, 20 Mar 2021 13:37:03 +0000 Message-Id: <20210320133706.21475-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210320133706.21475-1-alex.bennee@linaro.org> References: <20210320133706.21475-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x535.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Thomas Huth , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Thomas Huth The test for 128-bit atomics is causing trouble with FreeBSD 12.2 and --enable-werror: cc -Werror -fPIE -DPIE -std=3Dgnu99 -Wall -m64 -mcx16 -D_GNU_SOURCE -D_FIL= E_OFFSET_BITS=3D64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decl= s -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-co= mmon -fwrapv -Wold-style-definition -Wtype-limits -Wformat-security -Wforma= t-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendi= f-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-inc= lude-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redef= inition -Wno-tautological-type-limit-compare -fstack-protector-strong -o co= nfig-temp/qemu-conf.exe config-temp/qemu-conf.c -pie -Wl,-z,relro -Wl,-z,no= w -m64 -fstack-protector-strong config-temp/qemu-conf.c:4:7: error: implicit declaration of function '__at= omic_load_16' is invalid in C99 [-Werror,-Wimplicit-function-declaration] y =3D __atomic_load_16(&x, 0); ^ config-temp/qemu-conf.c:5:3: error: implicit declaration of function '__at= omic_store_16' is invalid in C99 [-Werror,-Wimplicit-function-declaration] __atomic_store_16(&x, y, 0); ^ config-temp/qemu-conf.c:5:3: note: did you mean '__atomic_load_16'? config-temp/qemu-conf.c:4:7: note: '__atomic_load_16' declared here y =3D __atomic_load_16(&x, 0); ^ config-temp/qemu-conf.c:6:3: error: implicit declaration of function '__at= omic_compare_exchange_16' is invalid in C99 [-Werror,-Wimplicit-function-de= claration] __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0); ^ 3 errors generated. Looking for they way we are using atomic functions in QEMU, we are not using these functions with the _16 suffix anyway. Switch to the same functions that we use in the include/qemu/atomic.h header. Signed-off-by: Thomas Huth Message-Id: <20210317110512.583747-2-thuth@redhat.com> Acked-by: Paolo Bonzini Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 847bc4d095..1be6bcec0a 100755 --- a/configure +++ b/configure @@ -4779,9 +4779,9 @@ if test "$int128" =3D "yes"; then int main(void) { unsigned __int128 x =3D 0, y =3D 0; - y =3D __atomic_load_16(&x, 0); - __atomic_store_16(&x, y, 0); - __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0); + y =3D __atomic_load(&x, 0); + __atomic_store(&x, y, 0); + __atomic_compare_exchange(&x, &y, x, 0, 0, 0); return 0; } EOF --=20 2.20.1 From nobody Wed Apr 24 05:32:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616247754; cv=none; d=zohomail.com; s=zohoarc; b=MUV2rB1NYU7KnN/5lZiy/9u9Jn2g8sXtSmcvx78/e+KE+VpsVldjIRVZhioUAlhe7VfOyPAFXvPlywX8CPZ8l251K4331iJdGYPblGy3O1kM+N83ZlvIUVVtPcCyXGhP7e5UJFwIZ2Y433t4MOT/uXSrSeWaf8HD810SKGMLbkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616247754; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VB8vRbSp2i9eXPvNVzkYpyqjXytH9giTdm7GR1EGSD0=; b=Y/iDfGF/Dq5hk+8eCmzhsJfSRw8fB5yg4heN34C5i0EBUGGgA2fRw2ztDW/+ix84SazgMasb1QX7pCRi3XhlB1qW/nOakWfZjD+WweKw/+ZgfUNOY2/S7lGUk4Tx5hBSawxI6ev1y6LZEaM0wNe+M3GvC7Yl4TJja/EYc+hQUmw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616247754561503.3388193981847; Sat, 20 Mar 2021 06:42:34 -0700 (PDT) Received: from localhost ([::1]:57942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbs8-0008JL-VF for importer@patchew.org; Sat, 20 Mar 2021 09:42:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNbnK-0003Cs-9c for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:39 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]:42934) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNbnC-0004Jl-Gv for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:37:34 -0400 Received: by mail-ej1-x636.google.com with SMTP id hq27so14059455ejc.9 for ; Sat, 20 Mar 2021 06:37:24 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id n3sm5322253ejj.113.2021.03.20.06.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:37:18 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D7EBA1FF9B; Sat, 20 Mar 2021 13:37:07 +0000 (GMT) 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=VB8vRbSp2i9eXPvNVzkYpyqjXytH9giTdm7GR1EGSD0=; b=poxqoFCmfrxVcc45IjXTwel7jkv/CR5rcjlUEGLb2tBnJot4I6Ka+5JEqv+pRl/UuV p9Mmtqu7QnxZ+nLjigumQbbYvUYfC3mQB13BhhiDNhbnXRqgx+SjBLZyPfuRXJXiy7N8 gl1R9OYenkhePTtGgdhMZyXwbwN6k8CGU1TaoaPdAxBO+WsxW9Y8dgTEouxOCd+g6goB zcCkvOcrVOXOCw6iVMBsfSEJx5dVb49NwhZq+qtEd3CEaVrBYi5rHA8iPVhD/a1Ur518 WuccR5THml+hPDV2BqcAOKRoGhf1e+eiWpqGuD/i9A0JA49EG8ejXVTgorjdJ23hYV5t WYSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VB8vRbSp2i9eXPvNVzkYpyqjXytH9giTdm7GR1EGSD0=; b=H+kpuPA2AQOFvufmHyTQAvUdkb0IYuBDt5mJtkurIjoRsm3ZI0ZlP6paUur58gNQcK AXOYR9y2YC1HztuNaavgJPCeAqKxOZwQfyNUq7hA7RAzT0j9l0xVg9GDEdUqVZgUaF+h cR2bv79yf3tHZ24BRokYjCDK9yHWYoI+jfZafnWosmC88I+gdg7Yyj9ZxeaUe3EvuO7A ywrNmekumpDStUzpUDGbjO3dx+rL0NyLXoz3zZzR3XFPlSZf2ocp0wFTWvlPKBW09Gli NaViN3DSpOX53Qitakpk7SV8Gf9UG4/ugKqAqbiwfmliF0RdEoYMof2vxackpOYKfitf Le+Q== X-Gm-Message-State: AOAM533X0ycgC3kbyyPC4jkN95ef9VZ1TJDxARa1Fe5R6WGVFnDxcpjX N8281DJwu2e1goT9lPtr60q4Uw== X-Google-Smtp-Source: ABdhPJwfbmyz6ta4gkdXbmyqs5qR2/Zz419kN3yvxI4trRcRqgLzpXGefIva9V1IokNfMfoMBVlb2w== X-Received: by 2002:a17:906:ac6:: with SMTP id z6mr9609147ejf.505.1616247443508; Sat, 20 Mar 2021 06:37:23 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 12/14] cirrus.yml: Update the FreeBSD task to version 12.2 Date: Sat, 20 Mar 2021 13:37:04 +0000 Message-Id: <20210320133706.21475-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210320133706.21475-1-alex.bennee@linaro.org> References: <20210320133706.21475-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x636.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ed Maste , Thomas Huth , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Li-Wen Hsu , Yonggang Luo Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Thomas Huth FreeBSD version 12.1 is out of service now, and the task in the Cirrus-CI is failing. Update to 12.2 to get it working again. Unfortunately, there is a bug in libtasn1 that triggers with the new version of Clang that is used there (see this thread for details: https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg00739.html ), so we have to disable gnutls for now to make it work again. We can enable it later again once libtasn1 has been fixed in FreeBSD. Signed-off-by: Thomas Huth Message-Id: <20210319101402.48871-1-thuth@redhat.com> Signed-off-by: Alex Benn=C3=A9e --- .cirrus.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index bc40a0550d..f53c519447 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -3,7 +3,7 @@ env: =20 freebsd_12_task: freebsd_instance: - image_family: freebsd-12-1 + image_family: freebsd-12-2 cpu: 8 memory: 8G install_script: @@ -13,7 +13,10 @@ freebsd_12_task: script: - mkdir build - cd build - - ../configure --enable-werror || { cat config.log meson-logs/meson-lo= g.txt; exit 1; } + # TODO: Enable gnutls again once FreeBSD's libtasn1 got fixed + # See: https://gitlab.com/gnutls/libtasn1/-/merge_requests/71 + - ../configure --enable-werror --disable-gnutls + || { cat config.log meson-logs/meson-log.txt; exit 1; } - gmake -j$(sysctl -n hw.ncpu) - gmake -j$(sysctl -n hw.ncpu) check V=3D1 =20 --=20 2.20.1 From nobody Wed Apr 24 05:32:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616248049; cv=none; d=zohomail.com; s=zohoarc; b=BRQ0yRuyekoylseAzHDazFPEhf6gpnfl09nhZaEqznvGFHIMlbDaE4AZPg/QRt+D+8ETi7mv7IvsHCYeSBobTJM0ph8obH6antifBJlF3udWGRCbNrC1gQA4+RXLRSxD30vG7N7FUu2FuwLJPJCipna0yNVFwqa9iYKT6yHl5uQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616248049; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TZzbS0oW3oHhvrKUDiA6aAQNFJJzORAw18XrtKz1I80=; b=W3Qs7nu/U73C5CXDvN9lRK9/xRPvvfJgrzZ6EKl/UMf2u0WwhywlS8VRAVO43vl5hHVKGLL9/czdBM7dEvAK4I8RglA0bFHNcIox+KhAvZzolKX5v7CSir3E3+6uT/wDpdUoxD36CQ7MZtFQeFnzL2Nc9UVAQfE75gf3LvkJEjg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616248049140497.11826346963323; Sat, 20 Mar 2021 06:47:29 -0700 (PDT) Received: from localhost ([::1]:41492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbwu-0004u4-22 for importer@patchew.org; Sat, 20 Mar 2021 09:47:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNbuU-00033I-2l for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:44:58 -0400 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]:43929) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNbuQ-0007yk-BE for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:44:57 -0400 Received: by mail-ed1-x52d.google.com with SMTP id e7so14003361edu.10 for ; Sat, 20 Mar 2021 06:44:53 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z9sm6409043edr.75.2021.03.20.06.44.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:44:49 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id EFD541FF9C; Sat, 20 Mar 2021 13:37:07 +0000 (GMT) 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=TZzbS0oW3oHhvrKUDiA6aAQNFJJzORAw18XrtKz1I80=; b=dMa5gNuve6i/4xyx45WnB2F4XgN0aMnkihW3VoioekGFG1WxQ/5xiTBl12Qpk5YzNr 99M6Jl0dXnaWa5DMJiV72cOPN5PP6XxKpQDKcN8Sh7kO9t0SHMBeMShDkle1G0KYc3qs toOWwx6Dp7ScoNisaNOzBEIs6AWC/w60H/rQ1qAFocN5C7aEiFjgQCFpKOPNgHw3C0j/ pWBzM17iEik0LWCHbDa/Us/6p5EuzNfMgtx0ovpgd35pyA8RR/LvXRc2hmiu0QBnsqpD YEvzLqN68Xkdg/42giu1rJstjhoMnhUaoUu3Q4oVYIb9IuFmXDA0emZ2UD9ZlFoGg4yi ZWtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TZzbS0oW3oHhvrKUDiA6aAQNFJJzORAw18XrtKz1I80=; b=k6j7J9ZWV7IWfe4GO5IhHkuEay3+d/OqHh1H/wrJkI1D33gqUuO6RbMgnpwnhMG6xN +uA+/5zfYJ4xQXPiKe930kty5LMeOIj8rFBb4DWIry19WCZKwyR0mRSP2Wo6um5wa+N2 yoTrXSkcQzs0C+OiFFJ6YeXqg/4gWKrY4o9O2IupOFhw+/Qzy0Odtp5ScX65yZmS1aRR nWda/Wn5UihpZBQRnC1+CVIOBqLZT3DniHToeVIRt1aqBYec8MtG2e4OnpVEbYHD75qM Kyq9XLIyaX2h65MUrfurcAgyKITg0/l5bh6n22zoreAt8aSegr+Uu2bAjeYDMvfiofvi vJWQ== X-Gm-Message-State: AOAM530/743zLByNLJ1PTtgnb2vfmrAMgvqLwmi2hH2LGik+4dXtn+Ri d9TrRdKYmL5GDZ71SYo77Nc5AA== X-Google-Smtp-Source: ABdhPJzJRZAaHAx0fDEqx4R1Z7vdZgTsDRfre4yF5xoEEdfhdJfV2qOUERdf9zLOBu9pkGQBBYZDyQ== X-Received: by 2002:a05:6402:512:: with SMTP id m18mr15307217edv.372.1616247892067; Sat, 20 Mar 2021 06:44:52 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 13/14] utils: Tighter tests for qemu_strtosz Date: Sat, 20 Mar 2021 13:37:05 +0000 Message-Id: <20210320133706.21475-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210320133706.21475-1-alex.bennee@linaro.org> References: <20210320133706.21475-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52d.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Eric Blake Our tests were not validating the return value in all cases, nor was it guaranteeing our documented claim that 'res' is unchanged on error. For that matter, it wasn't as thorough as the existing tests for qemu_strtoi() and friends for proving that endptr and res are sanely set. Enhancing the test found one case where we violated our documentation: namely, when failing with EINVAL when endptr is NULL, we shouldn't modify res. Signed-off-by: Eric Blake Reviewed-by: Thomas Huth Message-Id: <20210317143325.2165821-2-eblake@redhat.com> Signed-off-by: Alex Benn=C3=A9e --- tests/unit/test-cutils.c | 117 +++++++++++++++++++++++++++++++++++++-- util/cutils.c | 4 +- 2 files changed, 114 insertions(+), 7 deletions(-) diff --git a/tests/unit/test-cutils.c b/tests/unit/test-cutils.c index e025b54c05..5908de4fd0 100644 --- a/tests/unit/test-cutils.c +++ b/tests/unit/test-cutils.c @@ -1952,9 +1952,11 @@ static void test_qemu_strtosz_simple(void) const char *str; const char *endptr; int err; - uint64_t res =3D 0xbaadf00d; + uint64_t res; =20 str =3D "0"; + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 0); @@ -1962,6 +1964,8 @@ static void test_qemu_strtosz_simple(void) =20 /* Leading 0 gives decimal results, not octal */ str =3D "08"; + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 8); @@ -1969,46 +1973,61 @@ static void test_qemu_strtosz_simple(void) =20 /* Leading space is ignored */ str =3D " 12345"; + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 12345); g_assert(endptr =3D=3D str + 6); =20 + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, NULL, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 12345); =20 str =3D "9007199254740991"; /* 2^53-1 */ + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 0x1fffffffffffff); g_assert(endptr =3D=3D str + 16); =20 str =3D "9007199254740992"; /* 2^53 */ + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 0x20000000000000); g_assert(endptr =3D=3D str + 16); =20 str =3D "9007199254740993"; /* 2^53+1 */ + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 0x20000000000001); g_assert(endptr =3D=3D str + 16); =20 str =3D "18446744073709549568"; /* 0xfffffffffffff800 (53 msbs set) */ + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 0xfffffffffffff800); g_assert(endptr =3D=3D str + 20); =20 str =3D "18446744073709550591"; /* 0xfffffffffffffbff */ + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 0xfffffffffffffbff); g_assert(endptr =3D=3D str + 20); =20 str =3D "18446744073709551615"; /* 0xffffffffffffffff */ + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 0xffffffffffffffff); @@ -2020,21 +2039,27 @@ static void test_qemu_strtosz_hex(void) const char *str; const char *endptr; int err; - uint64_t res =3D 0xbaadf00d; + uint64_t res; =20 str =3D "0x0"; + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 0); g_assert(endptr =3D=3D str + 3); =20 str =3D "0xab"; + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 171); g_assert(endptr =3D=3D str + 4); =20 str =3D "0xae"; + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 174); @@ -2053,44 +2078,60 @@ static void test_qemu_strtosz_units(void) const char *e =3D "1E"; int err; const char *endptr; - uint64_t res =3D 0xbaadf00d; + uint64_t res; =20 /* default is M */ + endptr =3D NULL; + res =3D 0xbaadf00d; err =3D qemu_strtosz_MiB(none, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, MiB); g_assert(endptr =3D=3D none + 1); =20 + endptr =3D NULL; + res =3D 0xbaadf00d; err =3D qemu_strtosz(b, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 1); g_assert(endptr =3D=3D b + 2); =20 + endptr =3D NULL; + res =3D 0xbaadf00d; err =3D qemu_strtosz(k, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, KiB); g_assert(endptr =3D=3D k + 2); =20 + endptr =3D NULL; + res =3D 0xbaadf00d; err =3D qemu_strtosz(m, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, MiB); g_assert(endptr =3D=3D m + 2); =20 + endptr =3D NULL; + res =3D 0xbaadf00d; err =3D qemu_strtosz(g, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, GiB); g_assert(endptr =3D=3D g + 2); =20 + endptr =3D NULL; + res =3D 0xbaadf00d; err =3D qemu_strtosz(t, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, TiB); g_assert(endptr =3D=3D t + 2); =20 + endptr =3D NULL; + res =3D 0xbaadf00d; err =3D qemu_strtosz(p, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, PiB); g_assert(endptr =3D=3D p + 2); =20 + endptr =3D NULL; + res =3D 0xbaadf00d; err =3D qemu_strtosz(e, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, EiB); @@ -2102,9 +2143,11 @@ static void test_qemu_strtosz_float(void) const char *str; int err; const char *endptr; - uint64_t res =3D 0xbaadf00d; + uint64_t res; =20 str =3D "0.5E"; + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, EiB / 2); @@ -2112,6 +2155,8 @@ static void test_qemu_strtosz_float(void) =20 /* For convenience, a fraction of 0 is tolerated even on bytes */ str =3D "1.0B"; + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 1); @@ -2119,6 +2164,8 @@ static void test_qemu_strtosz_float(void) =20 /* An empty fraction is tolerated */ str =3D "1.k"; + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 1024); @@ -2126,6 +2173,8 @@ static void test_qemu_strtosz_float(void) =20 /* For convenience, we permit values that are not byte-exact */ str =3D "12.345M"; + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, (uint64_t) (12.345 * MiB + 0.5)); @@ -2140,67 +2189,91 @@ static void test_qemu_strtosz_invalid(void) uint64_t res =3D 0xbaadf00d; =20 str =3D ""; + endptr =3D NULL; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, -EINVAL); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); g_assert(endptr =3D=3D str); =20 str =3D " \t "; + endptr =3D NULL; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, -EINVAL); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); g_assert(endptr =3D=3D str); =20 str =3D "crap"; + endptr =3D NULL; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, -EINVAL); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); g_assert(endptr =3D=3D str); =20 str =3D "inf"; + endptr =3D NULL; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, -EINVAL); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); g_assert(endptr =3D=3D str); =20 str =3D "NaN"; + endptr =3D NULL; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, -EINVAL); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); g_assert(endptr =3D=3D str); =20 /* Fractional values require scale larger than bytes */ str =3D "1.1B"; + endptr =3D NULL; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, -EINVAL); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); g_assert(endptr =3D=3D str); =20 str =3D "1.1"; + endptr =3D NULL; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, -EINVAL); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); g_assert(endptr =3D=3D str); =20 /* No floating point exponents */ str =3D "1.5e1k"; + endptr =3D NULL; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, -EINVAL); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); g_assert(endptr =3D=3D str); =20 str =3D "1.5E+0k"; + endptr =3D NULL; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, -EINVAL); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); g_assert(endptr =3D=3D str); =20 /* No hex fractions */ str =3D "0x1.8k"; + endptr =3D NULL; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, -EINVAL); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); g_assert(endptr =3D=3D str); =20 /* No negative values */ str =3D "-0"; + endptr =3D NULL; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, -EINVAL); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); g_assert(endptr =3D=3D str); =20 str =3D "-1"; + endptr =3D NULL; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, -EINVAL); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); g_assert(endptr =3D=3D str); } =20 @@ -2209,48 +2282,72 @@ static void test_qemu_strtosz_trailing(void) const char *str; const char *endptr; int err; - uint64_t res =3D 0xbaadf00d; + uint64_t res; =20 str =3D "123xxx"; + endptr =3D NULL; + res =3D 0xbaadf00d; err =3D qemu_strtosz_MiB(str, &endptr, &res); + g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 123 * MiB); g_assert(endptr =3D=3D str + 3); =20 + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, NULL, &res); g_assert_cmpint(err, =3D=3D, -EINVAL); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); =20 str =3D "1kiB"; + endptr =3D NULL; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 1024); g_assert(endptr =3D=3D str + 2); =20 + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, NULL, &res); g_assert_cmpint(err, =3D=3D, -EINVAL); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); =20 str =3D "0x"; + endptr =3D NULL; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); + g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 0); g_assert(endptr =3D=3D str + 1); =20 + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, NULL, &res); g_assert_cmpint(err, =3D=3D, -EINVAL); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); =20 str =3D "0.NaN"; + endptr =3D NULL; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); + g_assert_cmpint(res, =3D=3D, 0); g_assert(endptr =3D=3D str + 2); =20 + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, NULL, &res); g_assert_cmpint(err, =3D=3D, -EINVAL); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); =20 str =3D "123-45"; + endptr =3D NULL; + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, &endptr, &res); + g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 123); g_assert(endptr =3D=3D str + 3); =20 + res =3D 0xbaadf00d; err =3D qemu_strtosz(str, NULL, &res); g_assert_cmpint(err, =3D=3D, -EINVAL); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); } =20 static void test_qemu_strtosz_erange(void) @@ -2261,13 +2358,17 @@ static void test_qemu_strtosz_erange(void) uint64_t res =3D 0xbaadf00d; =20 str =3D "18446744073709551616"; /* 2^64; see strtosz_simple for 2^64-1= */ + endptr =3D NULL; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, -ERANGE); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); g_assert(endptr =3D=3D str + 20); =20 str =3D "20E"; + endptr =3D NULL; err =3D qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, -ERANGE); + g_assert_cmpint(res, =3D=3D, 0xbaadf00d); g_assert(endptr =3D=3D str + 3); } =20 @@ -2276,15 +2377,19 @@ static void test_qemu_strtosz_metric(void) const char *str; int err; const char *endptr; - uint64_t res =3D 0xbaadf00d; + uint64_t res; =20 str =3D "12345k"; + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz_metric(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 12345000); g_assert(endptr =3D=3D str + 6); =20 str =3D "12.345M"; + endptr =3D str; + res =3D 0xbaadf00d; err =3D qemu_strtosz_metric(str, &endptr, &res); g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 12345000); diff --git a/util/cutils.c b/util/cutils.c index c442882b88..b425ed6570 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -362,7 +362,6 @@ static int do_strtosz(const char *nptr, const char **en= d, } } =20 - *result =3D val; retval =3D 0; =20 out: @@ -371,6 +370,9 @@ out: } else if (*endptr) { retval =3D -EINVAL; } + if (retval =3D=3D 0) { + *result =3D val; + } =20 return retval; } --=20 2.20.1 From nobody Wed Apr 24 05:32:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616248236; cv=none; d=zohomail.com; s=zohoarc; b=YAvyR+WIhO6RDjGM//P6g8NL0j0fQO/vPiNz19JQzNyE4DcI6cjORPTgtZJn/0VHbvv++GTJAvFXyppuu7MzhjRY8X9Y5je5dtbcYDREp843KO8nC/H4StXf+oq7jl9t48bJ++QXX59GS7KBlPwxqshsyIp6PwylfoLrsBTIuK8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616248236; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uL96Uis9yF2paA0n5GhgWk7dCyVBjyOpNhr7RDd2Ljw=; b=X45QVQ80mfA/S7982s0bw0V+eh49KYwGwTwsuraAKrvQBV+3t0tCfPvop5PY+9BwC02EtqehhJl2N2y62fYHyRwS2IMAXxpsaCl5O7Cj+2w+4+pMgKsog5kX8mIO+nPMVk/aL/KPLyUBpstNaBuBy3IR5fFwQF0WlwxpwxA+k+w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616248236429503.1023393796802; Sat, 20 Mar 2021 06:50:36 -0700 (PDT) Received: from localhost ([::1]:50068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbzu-00007k-RK for importer@patchew.org; Sat, 20 Mar 2021 09:50:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNbuT-000323-Ab for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:44:57 -0400 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]:43797) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNbuP-0007yg-44 for qemu-devel@nongnu.org; Sat, 20 Mar 2021 09:44:57 -0400 Received: by mail-ej1-x62f.google.com with SMTP id l4so14058587ejc.10 for ; Sat, 20 Mar 2021 06:44:52 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g21sm5335707ejd.6.2021.03.20.06.44.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 06:44:49 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1168B1FF9D; Sat, 20 Mar 2021 13:37:08 +0000 (GMT) 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=uL96Uis9yF2paA0n5GhgWk7dCyVBjyOpNhr7RDd2Ljw=; b=vNgvsdRZRpu65j5WOpju5KTzkw6uCxbQAsUj1/FhmdxO4g61GvNPg5piF4pY3DBwT7 SA+3RxhHCzSlbBujrC9ShlcRsPPfvfeJeX0vmKbBZlyDtT1GgtwFp8xBQvk+/WkM9r3x wpygDw4v56E9JCLWJAJHTfDGzudcIV1+SbJOEqrFc0kSgDy7si/bLCRO+2wNoKmsqaPq w88gOJ0ewE9beDLp81BlwjrN+OwwfuVjuN4GcLeghRoyjHoVP0MGwHrhXr4G/STP9GW0 msM2Y6VroqBsxKkLYZCUBQzBIL+nTCM+4kQCR/vu7EajU1bBEJ//gXPLmfitd6LnK3Sm S5IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uL96Uis9yF2paA0n5GhgWk7dCyVBjyOpNhr7RDd2Ljw=; b=NeL/3wColLIYAzI5Vq63DNatCLGe+jhVG0RI246baf0lLaGW76Kwfeao1tHyiXLb8I Du895YgayCT2WemambpjanIYsuEepXz/uNyOCAD2YbWuuRGYebUA/ZFUZKTNu/chLo4n yvAnnfzXqcBgIEf6AcQTKighIp5nloneeE6c/DaU0bg7Dl+WcR6xoiOcHDke9BO1aKzK jCSPnPQW1FrUaU6IPKL4TWTt/hRO6+6Z1s6V5rCqoa5gBhTJg1Xypix33u/wNUhhm0YZ kZtodlbapwGTaA0HbSxve1OArCTcicDi2/3trLq+Ha40YarRES/pa8HcQdYEfil7MAKI 3r1A== X-Gm-Message-State: AOAM531RNBce9WqhZy3T7VJMKJKHeQKNoZXw2981itSe4PZ37o7DmrRJ uWoauZdhGM9Hh2iapX5g0d5jAw== X-Google-Smtp-Source: ABdhPJxxqEA3br//HlkRQN/BAf5xSuVH8oQsxzOHyvbxs6+7PISOJQsJT7Uhj93DUHZKheke8fIgkA== X-Received: by 2002:a17:906:9152:: with SMTP id y18mr9872282ejw.19.1616247891424; Sat, 20 Mar 2021 06:44:51 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 14/14] utils: Work around mingw strto*l bug with 0x Date: Sat, 20 Mar 2021 13:37:06 +0000 Message-Id: <20210320133706.21475-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210320133706.21475-1-alex.bennee@linaro.org> References: <20210320133706.21475-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62f.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Eric Blake Mingw recognizes that "0x" has value 0 without setting errno, but fails to advance endptr to the trailing garbage 'x'. This in turn showed up in our recent testsuite additions for qemu_strtosz (commit 1657ba44b4 utils: Enhance testsuite for do_strtosz()); adjust our remaining tests to show that we now work around this windows bug. This patch intentionally fails check-syntax for use of strtol. Signed-off-by: Eric Blake Reviewed-by: Thomas Huth Message-Id: <20210317143325.2165821-3-eblake@redhat.com> Signed-off-by: Alex Benn=C3=A9e --- tests/unit/test-cutils.c | 54 ++++++++++++++++++++++++++++++++++++++++ util/cutils.c | 29 +++++++++++++++------ 2 files changed, 75 insertions(+), 8 deletions(-) diff --git a/tests/unit/test-cutils.c b/tests/unit/test-cutils.c index 5908de4fd0..98671f1ac3 100644 --- a/tests/unit/test-cutils.c +++ b/tests/unit/test-cutils.c @@ -378,6 +378,15 @@ static void test_qemu_strtoi_hex(void) g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 0x123); g_assert(endptr =3D=3D str + strlen(str)); + + str =3D "0x"; + res =3D 999; + endptr =3D &f; + err =3D qemu_strtoi(str, &endptr, 16, &res); + + g_assert_cmpint(err, =3D=3D, 0); + g_assert_cmpint(res, =3D=3D, 0); + g_assert(endptr =3D=3D str + 1); } =20 static void test_qemu_strtoi_max(void) @@ -669,6 +678,15 @@ static void test_qemu_strtoui_hex(void) g_assert_cmpint(err, =3D=3D, 0); g_assert_cmphex(res, =3D=3D, 0x123); g_assert(endptr =3D=3D str + strlen(str)); + + str =3D "0x"; + res =3D 999; + endptr =3D &f; + err =3D qemu_strtoui(str, &endptr, 16, &res); + + g_assert_cmpint(err, =3D=3D, 0); + g_assert_cmphex(res, =3D=3D, 0); + g_assert(endptr =3D=3D str + 1); } =20 static void test_qemu_strtoui_max(void) @@ -955,6 +973,15 @@ static void test_qemu_strtol_hex(void) g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 0x123); g_assert(endptr =3D=3D str + strlen(str)); + + str =3D "0x"; + res =3D 999; + endptr =3D &f; + err =3D qemu_strtol(str, &endptr, 16, &res); + + g_assert_cmpint(err, =3D=3D, 0); + g_assert_cmpint(res, =3D=3D, 0); + g_assert(endptr =3D=3D str + 1); } =20 static void test_qemu_strtol_max(void) @@ -1244,6 +1271,15 @@ static void test_qemu_strtoul_hex(void) g_assert_cmpint(err, =3D=3D, 0); g_assert_cmphex(res, =3D=3D, 0x123); g_assert(endptr =3D=3D str + strlen(str)); + + str =3D "0x"; + res =3D 999; + endptr =3D &f; + err =3D qemu_strtoul(str, &endptr, 16, &res); + + g_assert_cmpint(err, =3D=3D, 0); + g_assert_cmphex(res, =3D=3D, 0); + g_assert(endptr =3D=3D str + 1); } =20 static void test_qemu_strtoul_max(void) @@ -1528,6 +1564,15 @@ static void test_qemu_strtoi64_hex(void) g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, 0x123); g_assert(endptr =3D=3D str + strlen(str)); + + str =3D "0x"; + endptr =3D &f; + res =3D 999; + err =3D qemu_strtoi64(str, &endptr, 16, &res); + + g_assert_cmpint(err, =3D=3D, 0); + g_assert_cmpint(res, =3D=3D, 0); + g_assert(endptr =3D=3D str + 1); } =20 static void test_qemu_strtoi64_max(void) @@ -1815,6 +1860,15 @@ static void test_qemu_strtou64_hex(void) g_assert_cmpint(err, =3D=3D, 0); g_assert_cmphex(res, =3D=3D, 0x123); g_assert(endptr =3D=3D str + strlen(str)); + + str =3D "0x"; + endptr =3D &f; + res =3D 999; + err =3D qemu_strtou64(str, &endptr, 16, &res); + + g_assert_cmpint(err, =3D=3D, 0); + g_assert_cmphex(res, =3D=3D, 0); + g_assert(endptr =3D=3D str + 1); } =20 static void test_qemu_strtou64_max(void) diff --git a/util/cutils.c b/util/cutils.c index b425ed6570..ee908486da 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -396,9 +396,22 @@ int qemu_strtosz_metric(const char *nptr, const char *= *end, uint64_t *result) * Helper function for error checking after strtol() and the like */ static int check_strtox_error(const char *nptr, char *ep, - const char **endptr, int libc_errno) + const char **endptr, bool check_zero, + int libc_errno) { assert(ep >=3D nptr); + + /* Windows has a bug in that it fails to parse 0 from "0x" in base 16 = */ + if (check_zero && ep =3D=3D nptr && libc_errno =3D=3D 0) { + char *tmp; + + errno =3D 0; + if (strtol(nptr, &tmp, 10) =3D=3D 0 && errno =3D=3D 0 && + (*tmp =3D=3D 'x' || *tmp =3D=3D 'X')) { + ep =3D tmp; + } + } + if (endptr) { *endptr =3D ep; } @@ -465,7 +478,7 @@ int qemu_strtoi(const char *nptr, const char **endptr, = int base, } else { *result =3D lresult; } - return check_strtox_error(nptr, ep, endptr, errno); + return check_strtox_error(nptr, ep, endptr, lresult =3D=3D 0, errno); } =20 /** @@ -524,7 +537,7 @@ int qemu_strtoui(const char *nptr, const char **endptr,= int base, *result =3D lresult; } } - return check_strtox_error(nptr, ep, endptr, errno); + return check_strtox_error(nptr, ep, endptr, lresult =3D=3D 0, errno); } =20 /** @@ -566,7 +579,7 @@ int qemu_strtol(const char *nptr, const char **endptr, = int base, =20 errno =3D 0; *result =3D strtol(nptr, &ep, base); - return check_strtox_error(nptr, ep, endptr, errno); + return check_strtox_error(nptr, ep, endptr, *result =3D=3D 0, errno); } =20 /** @@ -613,7 +626,7 @@ int qemu_strtoul(const char *nptr, const char **endptr,= int base, if (errno =3D=3D ERANGE) { *result =3D -1; } - return check_strtox_error(nptr, ep, endptr, errno); + return check_strtox_error(nptr, ep, endptr, *result =3D=3D 0, errno); } =20 /** @@ -639,7 +652,7 @@ int qemu_strtoi64(const char *nptr, const char **endptr= , int base, QEMU_BUILD_BUG_ON(sizeof(int64_t) !=3D sizeof(long long)); errno =3D 0; *result =3D strtoll(nptr, &ep, base); - return check_strtox_error(nptr, ep, endptr, errno); + return check_strtox_error(nptr, ep, endptr, *result =3D=3D 0, errno); } =20 /** @@ -668,7 +681,7 @@ int qemu_strtou64(const char *nptr, const char **endptr= , int base, if (errno =3D=3D ERANGE) { *result =3D -1; } - return check_strtox_error(nptr, ep, endptr, errno); + return check_strtox_error(nptr, ep, endptr, *result =3D=3D 0, errno); } =20 /** @@ -708,7 +721,7 @@ int qemu_strtod(const char *nptr, const char **endptr, = double *result) =20 errno =3D 0; *result =3D strtod(nptr, &ep); - return check_strtox_error(nptr, ep, endptr, errno); + return check_strtox_error(nptr, ep, endptr, false, errno); } =20 /** --=20 2.20.1