From patchwork Sat Mar 20 13:36:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 405431 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2187518jai; Sat, 20 Mar 2021 06:39:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRqbGu9mrXqv2d2GzxFmWPJZ35bhB550nKqa4E+RaCwM2RK1gL6hsvPM8nau7bNo1u1BgP X-Received: by 2002:a25:4a84:: with SMTP id x126mr12695099yba.408.1616247559741; Sat, 20 Mar 2021 06:39:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616247559; cv=none; d=google.com; s=arc-20160816; b=nhiczsXZupic1Y2EAiftXQCB3UvXZKcwbLPpqbn11q4FhTeKZpYZ7r+Gvn2XUGE5Ar hsgkKjCi99jpUb74jfOytTPtRiKK92/Dws6XxGTA+DbuUFvTdNRfZZZsQzyHNltWJ9W3 qywk3bDAO/fKHkd74kOX6peM9JDAutAroZAepNAUr9cjCqoZ4nOGkg+GzCJeJybMy8Xa TFO19yEz2xIEwX58oMSrTYIT+eHRprWyHAXp/26mfhV1OVvFcMOWLXoOMEZ3Q1LRLNAp fYWG9nqpsDtmPJ8ZPIJiFmg+aAgHPwLyS0+W8dRHnUUdCgaD4kfH+kP46kwKfgRPIMWp ySXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=CCjBtNHV/27BIqfm5dJoDvU/LJdm3qeSBui9tlj/n/s=; b=Ok3G28VFsSyWG2tFY/paxRvZ6uQUrqOAZ4+LNiOLJkQP8fo1V0fR5n9ZcarlkjV7LH niFKYsTgCMIYRqKwdEyMLNf9yYAh2MD/fwmzr2XcmrZ/Fn6v1IPvndseEmYfdFKYZMU7 VOvV9MJ+ERbIvhV0QV3guf/aOjAC4whZHmoKOzhVKzWj7oi8AobzNGwjKog9x6yVvwXH Vid1dSTEAPDOyfOJSGKZUFox+zI8FU+hm4nfhrM2JeCNTWeZAzqcbT54Vftusi6HsUUX t8CBHbC687vop30jBAMgO8R2xbDKoY/WGq6HeOq12xX977PIq7mXoTxKEfECHJUc1n/a A3FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WH2HOUpp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a7si7276283ybp.480.2021.03.20.06.39.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Mar 2021 06:39:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WH2HOUpp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbp1-00032d-3x for patch@linaro.org; Sat, 20 Mar 2021 09:39:19 -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) 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-Received: by 2002:a17:906:1a44:: with SMTP id j4mr9883109ejf.401.1616247428722; Sat, 20 Mar 2021 06:37:08 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- scripts/kernel-doc | 3 +++ 1 file changed, 3 insertions(+) -- 2.20.1 Reviewed-by: Richard Henderson 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; + # Strip QEMU specific compiler annotations + $prototype =~ 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 From patchwork Sat Mar 20 13:36:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 405432 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2187523jai; Sat, 20 Mar 2021 06:39:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeAhGuJ7eOXdOdjssnE1h455b3rv5D/6w2wciHtOGO+fXV7+pUl5ivFIYx54iWzbhCYl5w X-Received: by 2002:a02:53:: with SMTP id 80mr5061076jaa.96.1616247560601; Sat, 20 Mar 2021 06:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616247560; cv=none; d=google.com; s=arc-20160816; b=orfODruGVlOyd1ZzRwcAQRyYoLRFbxX8RVWaqmsb2sSPMfiWrSNFQRcYjHvM+QOBgg R2f2Dj18KLAAIuNAC/dUnzbTzHS8wHkJwPmXwVeA5eF0jjxYzAk0fQRMaGKNfwOMR5yS 7oVcHkbmljuu0kEJZsvzCnH5Pwebktxt+eO5656YuSxyIPR3zjtiXMxLSpQs/DhHxXBo oKEpO+e+NY7VT1UbIosegAD6tHJc2vFEkgakPocFOD9Ea/JaXLNyjklrY1FANnqG+9Bi psPzSYu4tVt9E5de4UHDWV/WkReafWaKLms+TfrufvtMMyivp5uivBMq2lP9i5Lk2R+J SOZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=qI7RaKP8t/8kWu2Q3Cb45ubBjt2y6/gFWrDLRt5E2Mc=; b=j9iBJydmunHAakcUq9SOXlB7CFraIDv4GnahIR9y1jiYDB1+0R6VJY2MDtvmIutdQC qLSUhG7wReWZl6mwF7qd9JDxVikssfaDfe0ZwR9uoMp9+1oQPXo9Pb2b232aTfMblMM7 57wR0odDp+gUZDi1mcjdeIJp+VXY3N6ru3LQAK/Y/SZBVPEidMgOZQk/ZbCCMBhRVf7i e/c7MW7ZNftcF4IlYe0whmx6R74U31W0GwkUGuiXUX2ByKmKen040izfshstElnfYAxt ugKAkim+KH0nFtXW6Tv5AUC57FnM/udno+WgGr0+Jl/YRaPBtE5zj69cbhLPFu2eYrsq PIAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hx+UJ8US; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g19si5495319jat.91.2021.03.20.06.39.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Mar 2021 06:39:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hx+UJ8US; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbp1-00034Q-VZ for patch@linaro.org; Sat, 20 Mar 2021 09:39:19 -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) 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-Received: by 2002:a05:6402:27d4:: with SMTP id c20mr15658543ede.271.1616247430777; Sat, 20 Mar 2021 06:37:10 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Reviewed-by: Aaron Lindsay Message-Id: <20210312172821.31647-4-alex.bennee@linaro.org> --- docs/devel/tcg-plugins.rst | 5 +++++ 1 file changed, 5 insertions(+) -- 2.20.1 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 important that any information that is needed is extracted during the callback and saved by the plugin. +API +=== + +.. kernel-doc:: include/qemu/qemu-plugin.h + Usage ===== From patchwork Sat Mar 20 13:36:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 405439 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2189757jai; Sat, 20 Mar 2021 06:44:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3lRZ7JIGvDJR8Pg/jUzRE9/uTwqEi91TmbkR74/6bz8SIdui7vKEueE1CWTsSuW5Qr463 X-Received: by 2002:a25:25d7:: with SMTP id l206mr12838144ybl.43.1616247840918; Sat, 20 Mar 2021 06:44:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616247840; cv=none; d=google.com; s=arc-20160816; b=jKyCTABcLjvTyOLj6lMHOlC0Y9qkxgroXQ1WRJyqCCdjQAjkF75OSB5R9RMFO0mQJN VTgU4lJovUdX41X2+3VWdHjYRKReePlFibp3FD0MMvYhyRJm4pF2+QpeQnNIRz3N9ZkW q9xfyU2iyR0KUTs83GJP2uow38v7WYQjhDtvyjmu+ub/D0cVPyuRTw7S8Q8PQqSDd4wz cofS6lfFOYY8RcQ3lMmBKk7OAkx9VkXP5qChKYLwN8tPc8mfranSIxqh7bkZEBfU4uQI UJy7iVpmnaqthJRsP8jKCeA1awSsuKEs6GfbD0kIKxbMhUqZm7uyzuPruVCEqy/lMDmE n/YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=IM1oBayvdunRojoA3Pc9uJPF3Nk+3/AuR0/Svwaw3qQ=; b=RgtomkjVQg+Hv6Jr+uBJ3yIi1BJt364U4pBb9weV4kWWNNNxTTMXArI6Q1JdVXGn5b kqRd63rsxcQaSUQbXN5K3eBeJIUKI8cusDbvWCMdjpxPEUkUi5mqaajjTncULSq+Tcvz Lw4Bfb9HA8srbkT9OxH73qs6i9TGEN/nke3jBnMZato/UttF2AyZrrijPIsKCAEwYMBB YeJY9NbhxIOnktp4ICjaFhCiUJLcI843Ts+bnFeUkKh75F++QK6kWbrmBDiueASYrp7v d/Zg0fs3DOfYfcMRwHKLWE2tghLJPgKOwPPEKpbh9N0BwklTKCL0RAJFMAl7EK4cT/s5 rVJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FMVl8+T8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g36si5239302ybj.495.2021.03.20.06.44.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Mar 2021 06:44:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FMVl8+T8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbtY-0001fh-Bd for patch@linaro.org; Sat, 20 Mar 2021 09:44:00 -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) 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-Received: by 2002:a05:6402:5255:: with SMTP id t21mr15585751edd.91.1616247431818; Sat, 20 Mar 2021 06:37:11 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- docs/devel/style.rst | 46 ++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson 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 =========================== -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 following reasons: * It catches multiplication overflowing size_t; @@ -409,8 +429,8 @@ Declarations like are acceptable, though. -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. String manipulation =================== @@ -485,6 +505,8 @@ In addition, QEMU assumes that the compiler does not use 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. +.. _autofree-ref: + Automatic memory deallocation ============================= From patchwork Sat Mar 20 13:36:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 405433 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2187526jai; Sat, 20 Mar 2021 06:39:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRgnPEpTseh7MMpvio1Z9AMV/25QYuwgP+D85A+wsMIsIwoMek5W92xKH1aQStcmQN2DlV X-Received: by 2002:a05:6602:80d:: with SMTP id z13mr5846461iow.17.1616247560802; Sat, 20 Mar 2021 06:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616247560; cv=none; d=google.com; s=arc-20160816; b=o9avz7OCz1Z89TETVmADjO33shNdP9DABjL5FHU3HiO985DXSifcQmpV+QImgqHYPW IARHeipm9d1adn2YOKDDF5kkkh4P8wR9F8rtrkkZEnFsF3N+M5mweBpL5tJ23m1UwQG3 yS35cCEEFq1jr0xqqEy2v+o9JktsZ5kvNoTzqgZFK4AsNwRAeL+LAwCOexB9qfLV3SgI KrP4MHpivvdjELaj3Q7ku2jtGoH8RTMCTqysy1iFcddbYSHrGnp+1/cQPPTYqfqr4ZjY qdDWgtu2GcnUYC9/jHUzfQJY72mXdUdZfutCKd2NqCfRNdeiEvn/JszBM7YMmbQzX4l6 Zh9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ZwBf9UIhW9LVVf2kZJVAVnDApoNAfLOpIH7Z6bvZYNw=; b=JvmK4COGirujfX0CplwrTUd/r0sXWREdZnPwnQ4m6nyrzIme2RLV/z5W8NzXuEteu2 KiaW8BbuSLIi3XqSdvmWdVi5+frtRexGAxTnCA+Ic39vGJijQTIKyjxWtKlOpr6205m5 hga2VJUk9gcOsostAsphz2rJnnnn6ftJCZZB0nLwdztlXZmyKuMBCXds0JDupBAWssd1 s3hyLd8wqOMVwhR78MfVx7a2P47v9D3d1X95ZJQPfY7nYsvoVux5aZ4NpaBl8XsoUXv6 HeudGuAl2dE10RRpH2tNbxIwVR0P/5L4N4N2bkFgwq3jotp+jjjlSnI96mhngcGUo3hO e77g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=p4TgbYR9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w24si5680750jaq.43.2021.03.20.06.39.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Mar 2021 06:39:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=p4TgbYR9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbp2-00036U-7o for patch@linaro.org; Sat, 20 Mar 2021 09:39:20 -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) 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-Received: by 2002:a17:907:3da3:: with SMTP id he35mr9668684ejc.148.1616247433691; Sat, 20 Mar 2021 06:37:13 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= , "Dr. David Alan Gilbert" , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée 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(+) -- 2.20.1 Reviewed-by: Stefan Hajnoczi diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.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=PATH path for the vhost-user socket\n" + " --socket-group=GRNAME name of group for the vhost-user socket\n" " --fd=FDNUM fd number of vhost-user socket\n" " --thread-pool-size=NUM thread pool size limit (default %d)\n", THREAD_POOL_SIZE); From patchwork Sat Mar 20 13:36:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 405434 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2188335jai; Sat, 20 Mar 2021 06:40:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFbmJUlaDWc70rqWgp+gPBcs9juSdBBJQ6p2VlgDbEAQZTsLleLlAl2c8+j2w4L5s9Hd2w X-Received: by 2002:a05:6e02:1584:: with SMTP id m4mr1186553ilu.108.1616247654792; Sat, 20 Mar 2021 06:40:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616247654; cv=none; d=google.com; s=arc-20160816; b=tqy3WthQyxGHV5rTj/MFYbUiwcSyfB+fd7AYoE+gr/1JIB0X6BBO5sM170rMFoNqt6 tX2OiptyJRJnJDo+Xl+/mOBDWqV4wwfZYiPRh2V2/qy85C0rYq5JOffVn9JX/Kz3WoT7 5PQoTMjPlIyohwLOJUkz2+yUBa4zbeWHINcbYknlRvHp1fwdaGo/TQD1KzlBLe7zQGql qePawtcBvj5WAHk1d8zOLC3+Zj+k9V836HSceyLOCFyD+r8aazqWpD84tzrcvG5DeVHi caCnwdnGQLmfC9ygRPHAFy5jYg1jXf2onCWfKZyPUjvTcRfNGMwdDNJcUVFDVtPrsqZJ OaEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=tlo1IH59kp2yoMWTg8V5jw19LmnpM+/SiJZ1CFO2rII=; b=MmJnTku3bOZ4wGjKQlC+pTMVZGsNC5nPPbBbk22u491S6IXkYNBEm2/0vt2h1mj6gi O059g0VintLoN9LZyq3qQvwdBwkqWudrc/pXr8nQ+eAnat4CbLhe9kjXzQddZQg2Nm1x 7IPKHhD4S03sEtr7LonaX5ohSKuZYlioP/JAyadpH367f/c8OKZFC3G+SQFkCikXMghs IoTXaz/0kKcsV+GWMcBaCi90mQUJiapiASC81U75KCFOhTx9Sj4EKw58XkDIR+kqOBBN 4ffhzSkqz9VLd1sf93NupxTehFYuFdduKrM3/zy+GPgpP0e6Ikn2ZMX0Rqb9H28nJ1l6 dXoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=x49+cRAc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j9si5524963jaq.88.2021.03.20.06.40.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Mar 2021 06:40:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=x49+cRAc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbqY-0006aT-5R for patch@linaro.org; Sat, 20 Mar 2021 09:40:54 -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) 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-Received: by 2002:a17:906:5e01:: with SMTP id n1mr2951670eju.359.1616247434586; Sat, 20 Mar 2021 06:37:14 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Message-Id: <20210312102029.17017-2-alex.bennee@linaro.org> --- 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 => multiarch/arm-compat-semi}/semiconsole.c (93%) rename tests/tcg/{arm => multiarch/arm-compat-semi}/semihosting.c (85%) -- 2.20.1 Reviewed-by: Richard Henderson 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ée + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +uintptr_t __semi_call(uintptr_t type, uintptr_t arg0) +{ + register uintptr_t t asm("x0") = type; + register uintptr_t a0 asm("x1") = arg0; + asm("hlt 0xf000" + : "=r" (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ée @@ -7,13 +7,8 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -#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") = type; register uintptr_t a0 asm("r1") = arg0; #ifdef __thumb__ @@ -23,13 +18,5 @@ uintptr_t __semi_call(uintptr_t type, uintptr_t arg0) #endif asm(SVC : "=r" (t) : "r" (t), "r" (a0)); -#else - register uintptr_t t asm("x0") = type; - register uintptr_t a0 asm("x1") = arg0; - asm("hlt 0xf000" - : "=r" (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ée + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +uintptr_t __semi_call(uintptr_t type, uintptr_t arg0) +{ + register uintptr_t t asm("a0") = type; + register uintptr_t a0 asm("a1") = 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" + : "=r" (t) + : "r" (t), "r" (a0)); + return t; +} diff --git a/tests/tcg/arm/semiconsole.c b/tests/tcg/multiarch/arm-compat-semi/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 */ +#define SYS_READC 0x07 + #include #include #include "semicall.h" diff --git a/tests/tcg/arm/semihosting.c b/tests/tcg/multiarch/arm-compat-semi/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 */ +#define SYS_WRITE0 0x04 +#define SYS_REPORTEXC 0x18 + #include #include "semicall.h" int main(int argc, char *argv[argc]) { -#if defined(__arm__) +#if UINTPTR_MAX == UINT32_MAX uintptr_t exit_code = 0x20026; #else uintptr_t exit_block[2] = {0x20026, 0}; diff --git a/MAINTAINERS b/MAINTAINERS index 25fc49d1dc..b6e1b25b33 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3283,6 +3283,7 @@ M: Alex Bennée S: Maintained F: semihosting/ F: include/semihosting/ +F: tests/tcg/multiarch/arm-compat-semi/ 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 # for including , in command strings COMMA := , 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 += mte-1 mte-2 mte-3 mte-4 mte-%: CFLAGS += -march=armv8.5-a+memtag endif -# Semihosting smoke test for linux-user -AARCH64_TESTS += 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 += 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 += 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) +ifeq ($(CONFIG_ARM_COMPATIBLE_SEMIHOSTING),y) + # Semihosting smoke test for linux-user -ARM_TESTS += semihosting semihosting: CFLAGS += -mthumb -run-semihosting: semihosting - $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") ARM_TESTS += semihosting-arm -semihosting-arm: CFLAGS += -marm +semihosting-arm: CFLAGS += -marm -I$(SRC_PATH)/tests/tcg/$(TARGET_NAME) semihosting-arm: semihosting.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) run-semihosting-arm: semihosting-arm $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") -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 $*") -ARM_TESTS += semiconsole semiconsole-arm +ARM_TESTS += semiconsole-arm semiconsole: CFLAGS += -mthumb -run-semiconsole: semiconsole - $(call skip-test, $<, "MANUAL ONLY") -run-plugin-semiconsole-with-%: - $(call skip-test, $<, "MANUAL ONLY") - -semiconsole-arm: CFLAGS += -marm -semiconsole-arm: semiconsole.c +semiconsole-arm: CFLAGS += -marm -I$(SRC_PATH)/tests/tcg/$(TARGET_NAME) +semiconsole-arm: semihosting.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) run-semiconsole-arm: semiconsole-arm @@ -68,6 +62,8 @@ run-semiconsole-arm: semiconsole-arm run-plugin-semiconsole-arm-with-%: $(call skip-test, $<, "MANUAL ONLY") +endif + ARM_TESTS += commpage TESTS += $(ARM_TESTS) diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.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 += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read +# 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 += $(MULTIARCH_SRC)/arm-compat-semi + +# Add -I path back to TARGET_NAME for semicall.h +semihosting: CFLAGS+=-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+=-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 += semihosting semiconsole +endif # Update TESTS TESTS += $(MULTIARCH_TESTS) From patchwork Sat Mar 20 13:36:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 405442 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2191482jai; Sat, 20 Mar 2021 06:47:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzILSTCYRi7AlTwnXC3zP9B9zXUCbKRcEssV1BygiCaO6erb4fSK/EJxbLRudr5An8RpDGz X-Received: by 2002:a25:a16a:: with SMTP id z97mr12544668ybh.145.1616248037558; Sat, 20 Mar 2021 06:47:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616248037; cv=none; d=google.com; s=arc-20160816; b=Es/wxPiwo9V1pDfjBPGnDLy/3MK7+XRU0SkVqnkO1wFV3srnZS7u44PJ5dfPvglXKy sNiOIagCy5iVU3o4mGX+qRzqKmqFOUKWO72cEZFqPakML7i4Gy9Q+DHP9hAY/N8DKojK Hl+vI43oSn2oTYASgcx0luPlcubCMh1uPoHS0Kcs+Xbca15wYhXcfJE9kM/aGx9R6XR7 K71y4uYQFNbo8KHZ5ND5bK+i+NX+GVyMcvb6ofczNVe6FYe4b9Zwl8uNEjgHRB2CKeEh q3FuYqaNSGr+z69a3ur+XiO3kPktN/wNyABgHQrCAV39eFPdudxAU/27cIrBn+ZG2XiP ZOMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=rLEsx07yxF/Bt1JL1Eo30fED3vfHhKy7OHokAU6q/Nw=; b=P6VJFNOBRnR1Cp6Z9R9IdhXAds2FkJ21Xm3GFtNA/tEmYHZNIenla9MUI2avWJNRGh d9DoThbc0+5MAbfj86nAuuGU5UGdCzlAVjRXFJdUUAgGDHwyGfpbJqDrzWPqTYHVgmWE O51ciYNejAO6aca0xYqtwd2tTJ5nmXwCsym7uhffoxFkldfwRZ2NmGmCIbha7SEU9WNB Assv6FEF0BEYGNF0Ft1t6cGjUsu6U9aVjhyZTAagifDcFmBUy75Utu+uD76UDqS7WIFD qJcx8GvUcLq4c9VQtaNLNVxj9/F2vOgmlBdzISv85SJheqvP03+j7cDuUaazY3tavVqp uNkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="N8/2Ufst"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f184si7566027yba.156.2021.03.20.06.47.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Mar 2021 06:47:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="N8/2Ufst"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbwi-0004m0-To for patch@linaro.org; Sat, 20 Mar 2021 09:47:16 -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) 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-Received: by 2002:a17:907:162b:: with SMTP id hb43mr9855705ejc.41.1616247438881; Sat, 20 Mar 2021 06:37:18 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" >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ée 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(-) -- 2.20.1 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[] = { }, }; -/* 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 = 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[] = { } while (0) #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 -#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) == 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) == 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 = EFAULT; \ - return set_swi_errno(cs, -1); \ - } \ - } while (0) - -#define SET_ARG(n, val) \ - put_user_utl(val, args + (n) * sizeof(target_ulong)) -#endif /* * Do a semihosting call. From patchwork Sat Mar 20 13:36:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 405435 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2188344jai; Sat, 20 Mar 2021 06:40:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9z37oGDeaNBWuqpm/KQSm8DpBH+IZeRnniM73Sty/v0N8/xiVffyXGTKiHC20EsXWGpcv X-Received: by 2002:a25:850d:: with SMTP id w13mr13857304ybk.496.1616247655905; Sat, 20 Mar 2021 06:40:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616247655; cv=none; d=google.com; s=arc-20160816; b=C8nnHe53BjvLgX3WAPcNdqTHzdJaJoVntzqKiX42yw+MjrMXgRQZQO+rQT+t371M7Y U719FI8DBYSE1g38aAtp+ICMednQcA5JefRPxMNB8VdScMiXvaScaqbHD2vR10BJMp2/ fCvP+ZR1kyg3/kQ2bhzNU9CBCTcfYIpDThJCo9P3x53HhNNv1hHKpqdq/5kB6W9NZaTH S7mDWJ/pa4nN0sAQgTGlux/XJU9cFzQ+t4WxzjdwS75zYVgL1PTvvY5DBY2pEvm6QuSD BBJooClP2Ea05lygKYPpAUXoifAbkgXUx0ap5A6mn8Rw2zirSQrrlDrFDgX1BqWOTUBf cNjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=H/e/SdGSFzWo+xbjndfr99fhe97V2yal8vW6qxaRucA=; b=kBB5CrNZizkXocpRYRo1x92YjJg6+7Z1iLbFXBIcgIEUS2z1bYOKuSUmyOmSOb8k67 PusNThjff2MzStwA9mpGBI5JajaH1qTna0EuO9McmRQM96g4zTJBUtVIzf1CWXsGFFWn IVn9/e31MqdgJducK9iGf+VE/HD+xV/aWSSYOF742FMwK/VXCHnWG2aCC2a0gzB+76+D agCwJWIapqz1k3/XZqTXuXHMmM6XGUifCR1m9JM7sb6wQ76M6pjvZKFDhl4P/dp0GXI4 kr1YqdzCuiInV2ZbPT7sxXeNZi7A34fUSlq3LWLfDwv5hj/RjuIsl26G0BHBQUKc6RBE ikqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=pbpHF2Nt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r80si9115125ybc.88.2021.03.20.06.40.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Mar 2021 06:40:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=pbpHF2Nt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbqZ-0006e2-4y for patch@linaro.org; Sat, 20 Mar 2021 09:40:55 -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) 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-Received: by 2002:a17:906:d554:: with SMTP id cr20mr9859829ejc.61.1616247437251; Sat, 20 Mar 2021 06:37:17 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= , Bug 1915925 <1915925@bugs.launchpad.net> Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée 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(-) -- 2.20.1 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 = 0; i < ARRAY_SIZE(retvals); i++) { bool fail; - fail = SET_ARG(i, retvals[i]); + if (is_64bit_semihosting(env)) { + fail = put_user_u64(retvals[i], arg0 + i * 8); + } else { + fail = put_user_u32(retvals[i], arg0 + i * 4); + } if (fail) { /* Couldn't write back to argument block */ From patchwork Sat Mar 20 13:37:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 405438 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2189412jai; Sat, 20 Mar 2021 06:43:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuHneLQ0E5v6uJEE6apNdKT+Vvas+a6FJW93FuUxnqDGBTvxqWmg8uwenrXR9Aq2OsGCmV X-Received: by 2002:a25:d091:: with SMTP id h139mr12407660ybg.437.1616247799185; Sat, 20 Mar 2021 06:43:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616247799; cv=none; d=google.com; s=arc-20160816; b=sOpDMXQ2IYKzCFfiH27k8zWd1LUtyXv+vsvZTAcGNfTLL0Vvf7ihECZf9oYEI0b/if R65ju9bcI/3ejMTG4TATbIW5Mw5Vl6U6szR97zKa6ekbLRvX7f9fvvsCuMpFe5R5WunT cA6UCioQuJwBGPmOc+fRlmmrs/M4bxpQXmo8VmsrPhx/o3oEm4nKZGy7QkcLV4+mF3m/ 9CfiB2yuaMSOZAgIniw0zD8bVo1w0NrJKL6yUUT/9KkUmM/3NESJDVdaA3RrDrnhIKoa 15duSTjwLxP5C3JgQE/rQ8xw1g/yAxJ16/LztMpsIj4tm9geWbkyPRUMFo/gS+cM6sl7 m1gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=lOTtqQ1GqfCDk2mShrLCLuCwUnyYqPWN4bH2H+UmRI8=; b=dC1I8NkLUwSqAZa2SpoGmFyrIXrtgUpLo/F+iaGqMW5r3OFngTNZww65kIq1yHDypu mvI5wV6GsuU3xvszoeQ8n1O+m61Z9Ewhsu8kmjrmLIY+bhw+fvd3RniWQABlMafcPVjE ljkHWjtdxhmlR+WTI037zzL1y1n4E11L4cDCxYaWuIBzUtfKSQlySShuEKDPwzpoHt+R r/i98i5cb4Nb3Ou1Pz+g48AqOBZZ1bvSCS6xgsxXrwPsj2ExTr18WP6v1fZuWVrO60mL lXwJB6iI528yAUgDTvEJ7Okq1WL0dGKY3cy4ONrlBp/acqd1CDzUrmA8xS3vQOKHXl50 iAQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d6aEufXY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x16si2690772ybk.224.2021.03.20.06.43.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Mar 2021 06:43:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d6aEufXY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbss-0001gb-Jx for patch@linaro.org; Sat, 20 Mar 2021 09:43:18 -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) 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-Received: by 2002:a05:6402:614:: with SMTP id n20mr15344467edv.58.1616247436513; Sat, 20 Mar 2021 06:37:16 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Message-Id: <20210312102029.17017-5-alex.bennee@linaro.org> --- linux-user/riscv/cpu_loop.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.20.1 Reviewed-by: Richard Henderson 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 target_pt_regs *regs) error_report("Incompatible ELF: RVE cpu requires RVE ABI binary"); exit(EXIT_FAILURE); } + + ts->stack_base = info->start_stack; + ts->heap_base = info->brk; + /* This will be filled in on the first SYS_HEAPINFO call. */ + ts->heap_limit = 0; } From patchwork Sat Mar 20 13:37:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 405444 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2192819jai; Sat, 20 Mar 2021 06:49:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTrTNH8UbTGsdH2LHlF5RVrs8XkWfnJMEafWBS5zBTF+6SmwPHU0salcETPjxMh4hq1/QW X-Received: by 2002:a25:2b88:: with SMTP id r130mr13095802ybr.460.1616248199689; Sat, 20 Mar 2021 06:49:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616248199; cv=none; d=google.com; s=arc-20160816; b=HS+FfcvZMjFDploF7dVqwbZfTDn3Oz3RMRHraHMJiqCnLRoahEyNARLGS/yRD18DiF s0E3PnySA57cNdbJU+v5SJpgahnJ+bx5fYfEVADNulReBHQrIT/RUy7f0OK/m5zKT1vE tyoKbON9GO/fGgqh0aU4rOU4cfAUnEGq7//kWP3Tq/DmNMZ6QKMeUNCyI4f1yu0qVp4y typhABcBuMkgJB4x4Ybe6EAILYSqafsHs1iFs6zPFtG5Za+Ezb72QBTF4K6oYI/UOKOJ VD0pM6aZlIb7s8Tgdn9ZpbL4fqDq9wdRyq4lk2+s0+oLByXI86uVSZ+dBdytfO4VZRFH 2lEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Pa/Fiua7g7Vmj4OKm8oDu8MB1fXTUZdi8REKYNbvuPI=; b=xMSQk7vSmxIydwuK6UwEsL5eokQCKv3Q2xN0SUTSLaEOms8IqKZ80XBmul7TwyZwZY SLsZMN1MKQCguqDFBzyp3b3sC/h8X4nyEGhZlv0s7HydDkrzbGhU2p61HG33hSvlFxqw tXsq0vCEH3wfsvJZm6akbjevGEuNDUVotYW/zLLmCUcRmW/RGp3L04YEfha6hy0O3KrG NfiaMmc3RgaPmXB8gN/8/6+DT33Atv7rQXJ5hTsU15K8qJ8bdP6l8j/pLLDgkRm4DhU7 g/N5qI2ewHhoQmomaO4ihbQmJkc4lXZk2T9M7YTnwr3SujThoJ6i8Wv7hTkvZm8YBPCb yQxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XMtuW8cH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w8si7767561ybm.174.2021.03.20.06.49.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Mar 2021 06:49:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XMtuW8cH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbzL-0007qd-3V for patch@linaro.org; Sat, 20 Mar 2021 09:49:59 -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) 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-Received: by 2002:a17:906:1c98:: with SMTP id g24mr9843221ejh.51.1616247440703; Sat, 20 Mar 2021 06:37:20 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Query the SYS_HEAPINFO semicall and do some basic verification of the information via libc calls. Signed-off-by: Alex Bennée Message-Id: <20210312102029.17017-6-alex.bennee@linaro.org> --- .../multiarch/arm-compat-semi/semihosting.c | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) -- 2.20.1 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 @@ */ #define SYS_WRITE0 0x04 +#define SYS_HEAPINFO 0x16 #define SYS_REPORTEXC 0x18 #include +#include +#include +#include #include "semicall.h" int main(int argc, char *argv[argc]) @@ -21,8 +25,46 @@ int main(int argc, char *argv[argc]) uintptr_t exit_block[2] = {0x20026, 0}; uintptr_t exit_code = (uintptr_t) &exit_block; #endif + struct { + void *heap_base; + void *heap_limit; + void *stack_base; + void *stack_limit; + } info; + void *ptr_to_info = (void *) &info; - __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 == NULL || info.heap_limit == NULL) { + printf("null heap: %p -> %p\n", info.heap_base, info.heap_limit); + exit(1); + } else if (info.heap_base != NULL && info.heap_limit != NULL) { + /* Error if heap base is above limit */ + if ((uintptr_t) info.heap_base >= (uintptr_t) info.heap_limit) { + printf("heap base %p >= heap_limit %p\n", + info.heap_base, info.heap_limit); + exit(2); + } + } + + if (info.stack_base == NULL) { + printf("null stack: %p -> %p\n", info.stack_base, info.stack_limit); + exit(3); + } else if (info.stack_base != NULL && info.stack_limit != 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; From patchwork Sat Mar 20 13:37:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 405436 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2188347jai; Sat, 20 Mar 2021 06:40:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxywRi2dJQDBKEivT5Izd0V5UGT35vcbz+Cz9kjF+ePUlHYHz/vgiCaezEp6FUDXkB2DD9d X-Received: by 2002:a5e:c117:: with SMTP id v23mr5999881iol.54.1616247656042; Sat, 20 Mar 2021 06:40:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616247656; cv=none; d=google.com; s=arc-20160816; b=F8pjYGrknqX9pTKJ4xatnBNWfMI90/PDLK/KoThOZTjvhcinQHr4t6Pg9O7RqlRbVP xnv0KIzRpvUsz/ohv7rgAkHnsk7iLLvOExUnpxgKbTpfLZw4yi8BSBu+D/Xsz4dkrMc6 +fhcVWdnoy3rIkBO2dVAm447S/PwcGaXt9AwbjJ63MW9WXDphiJucIuWD6CtVBkFxlQR F+XhBQmiXBLcotQkdqDlvK3d1u8T7WuDv02baafrjCwIN5ATNAuTdLZETgaSXpVn2m3a g9VfgOOgI6QsrXjHxWbjzJp4k3deHNhFngsJVveZZM1GJH7YM3dLVyn8xN4T3drtbzqM 659w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=GabEOI8qt2VYTbFRWHqczSknP0jlmCGZSofoXChZAOc=; b=wRn4OWdoMjldY17b0j8mWKz1YJVtG90tJVJX7WBWWCHVC49m3oENCruQJ8tkuSKiq5 PwhLZji6bHVOtFBFmkoyi0LNrCUgtEkSm8hcTXLxWRvUKsgSciqpVCq3RK6IHZ3iqn+m HNnSD1GHZfVO5Big1GnylkTFebJ28c+PBDBx5wiIEkntvwKDVj8n0AIfr6/16qWpKqNy /q0ro5q6QFuwgbUuscgqhyc2h6QwnFWt7h+D+0W2Oh/eErtlJKyMDFIMW9YbAxPcOrVe bi0rsUx7pYq5JVSE7D8mgTvUZjOT+ZCjaW6Z2+V2EJ9U5JZnddoK25zJ/k4YfOZlEYz9 Nt3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="vTSOM5/g"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b5si5408922iok.57.2021.03.20.06.40.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Mar 2021 06:40:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="vTSOM5/g"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbqZ-0006f5-Ex for patch@linaro.org; Sat, 20 Mar 2021 09:40:55 -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) 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-Received: by 2002:a17:906:4747:: with SMTP id j7mr9634327ejs.221.1616247444264; Sat, 20 Mar 2021 06:37:24 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- .gitlab-ci.yml | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) -- 2.20.1 Reviewed-by: Willian Rampazzo 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=log,simple,syslog artifacts: expire_in: 2 days paths: @@ -605,7 +605,7 @@ tsan-build: variables: IMAGE: ubuntu2004 CONFIGURE_ARGS: --enable-tsan --cc=clang-10 --cxx=clang++-10 --disable-docs - --enable-fdt=system --enable-slirp=system + --enable-trace-backends=ust --enable-fdt=system --enable-slirp=system TARGETS: x86_64-softmmu ppc64-softmmu riscv64-softmmu x86_64-linux-user MAKE_CHECK_ARGS: bench V=1 @@ -702,6 +702,7 @@ build-coroutine-sigaltstack: variables: IMAGE: ubuntu2004 CONFIGURE_ARGS: --with-coroutine=sigaltstack --disable-tcg + --enable-trace-backends=ftrace MAKE_CHECK_ARGS: check-unit # Most jobs test latest gcrypt or nettle builds @@ -739,31 +740,6 @@ crypto-only-gnutls: MAKE_CHECK_ARGS: check -# 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=log,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=ftrace --target-list=x86_64-softmmu - -build-trace-ust-system: - <<: *native_build_job_definition - needs: - job: amd64-ubuntu2004-container - variables: - IMAGE: ubuntu2004 - CONFIGURE_ARGS: --enable-trace-backends=ust --target-list=x86_64-softmmu - # Check our reduced build configurations build-without-default-devices: <<: *native_build_job_definition From patchwork Sat Mar 20 13:37:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 405441 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2191343jai; Sat, 20 Mar 2021 06:47:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+70SsHy/Zhc8EGN44VmxQWKXnJB68Awwui0LaSze8zn3JmMfhypSgYXjvl6CCD7O8Wv4X X-Received: by 2002:a25:d802:: with SMTP id p2mr10184955ybg.89.1616248023201; Sat, 20 Mar 2021 06:47:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616248023; cv=none; d=google.com; s=arc-20160816; b=OiNtJ+xfbxdICIvbU2HJolmTv8oyx/eElZf7oHN87i+7g+n8TVmb4JtPsJNNY8/ROc hma8u8vlV4ams48L9t8YmE09GlPWFrPbWXRKQoo9HTJDwwWY1EasXUwfLxqjCYCrEAxR csPDsvBq0mzQn6hjHkRAmDfHf/g7LWHnr+8dzzmCVvcLcJvt1gcCBi8GnaPviqkVbqgW BchUBG/j28O7yd6h8bc0kaSsOHjvethBQcDqI9dB6WzMy1xR2I7K0NeW+vhpmXtP/nnJ ILS0KIH44rt4W8saulURLu7eJpzw6H69I1mCEdGwtlCiGHtMbumuTlcWyj20j54gTBUv 2mOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=xDQfMQ2++LPf2hEK5W0FEnogdPCtNwE5cK792H3OCyE=; b=lYiszvhL/ugmOlGMj+aygqDQI1TnYt1xV5sk0Rr58LsbeverrLTjabHU//oNzIS+3U xIEypsa7WHL5bRJNCrf7z3USqZ5i1afQjeShxrobq+l51lG1x3sNlgHNGRcH8PSlFEVZ bDihGjjWSohu8n7vi2sEYOPXb5gqpCqX5PFwcewp/uQ3RRMnfDnCs4RD+qnJV5pK85Im yJb23aOlVrC/kFnDrAWCdSyOdwEH7uTm3Oc3+JcHwysLMPLsKNQj3uSMJi6w51lQQmGq 0DTWbIIAEgxQ1PJpbi+wZxwVlOFPTgan2rokM220YFUfsYNXVyr49A8CzGQBh21LXKNv LWgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=v8a6cZu4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k187si7811784yba.204.2021.03.20.06.47.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Mar 2021 06:47:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=v8a6cZu4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbwU-00049z-Lf for patch@linaro.org; Sat, 20 Mar 2021 09:47:02 -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) 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-Received: by 2002:a05:6402:84b:: with SMTP id b11mr15281895edz.56.1616247441692; Sat, 20 Mar 2021 06:37:21 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= , Paolo Bonzini , Thomas Huth , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Thomas Huth The test for 128-bit atomics is causing trouble with FreeBSD 12.2 and --enable-werror: cc -Werror -fPIE -DPIE -std=gnu99 -Wall -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -fstack-protector-strong -o config-temp/qemu-conf.exe config-temp/qemu-conf.c -pie -Wl,-z,relro -Wl,-z,now -m64 -fstack-protector-strong config-temp/qemu-conf.c:4:7: error: implicit declaration of function '__atomic_load_16' is invalid in C99 [-Werror,-Wimplicit-function-declaration] y = __atomic_load_16(&x, 0); ^ config-temp/qemu-conf.c:5:3: error: implicit declaration of function '__atomic_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 = __atomic_load_16(&x, 0); ^ config-temp/qemu-conf.c:6:3: error: implicit declaration of function '__atomic_compare_exchange_16' is invalid in C99 [-Werror,-Wimplicit-function-declaration] __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ée --- configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/configure b/configure index 847bc4d095..1be6bcec0a 100755 --- a/configure +++ b/configure @@ -4779,9 +4779,9 @@ if test "$int128" = "yes"; then int main(void) { unsigned __int128 x = 0, y = 0; - y = __atomic_load_16(&x, 0); - __atomic_store_16(&x, y, 0); - __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0); + y = __atomic_load(&x, 0); + __atomic_store(&x, y, 0); + __atomic_compare_exchange(&x, &y, x, 0, 0, 0); return 0; } EOF From patchwork Sat Mar 20 13:37:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 405437 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2188364jai; Sat, 20 Mar 2021 06:40:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeS3Cy1e4+biqLosRXYvafMvd8B79JhlIOyswFTI+GdA/GCD1LiZOOYmnHJFIY5zyrsdUA X-Received: by 2002:a25:2cc1:: with SMTP id s184mr10644527ybs.377.1616247657836; Sat, 20 Mar 2021 06:40:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616247657; cv=none; d=google.com; s=arc-20160816; b=snSY5aofF1Dn0mH+DcrOXeAMdQx4S5OgVEmZ35GKc4fXQs2qaLsG52zY6r2SwI8n3F s49xpTzEKVVjQpgCHM+GfmnN10QpupqGHCWKXXQBstVcXT7XYvcug+hWGqd6lXRCM+aO dh6BxytG/ISHwx6//Wl7x64jTl311DNG63lTGtrvJqM4zV4oqu56ln08+PI8yCmpfuDJ VztXUlIvTKC4KyZZHU5dzw4lFKI1ss1mkYUZ2yWMR813QpmcwcEHmX/HzIdOwX1EuAFU TDIZWar/zNq54gKQjeW/AoCdYgLihOzdNj2qcBqO/Ls+4VlKGjueGT6pfI13ORB1Qw/L Rv5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=VB8vRbSp2i9eXPvNVzkYpyqjXytH9giTdm7GR1EGSD0=; b=JurXlPy+RDMxt+mxPz9g5C+u1gUgC+unvtUtGbT8XNDL8zZvy4zi/ZkMQcVkB4DF+Z APLdxDWfBUDX0G0B57v0mL9J2tS5Gc63ddVwzXNIhuzCl236CwYVQ4yCKFjyx8xmvC/L JpcHdRYxgPQl37ocXP/1NyE312mbEWkohPqDGzLR6ySci5IvUb02E47wkHstG4nUD8e0 U98n3Bvk5pN+TU+RTiG01HdDEOZHXEXma5gF4T3YhZ6wQqzgRanTb/vhEN9HAwX6u+xL VFl8b1DRkmixvlOulOuKL9EcDeEjyR0e8baIFQYxpnkhTNESAi12CvTgNsTVy9hkT3Xl jK5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=poxqoFCm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e31si9035403ybi.442.2021.03.20.06.40.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Mar 2021 06:40:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=poxqoFCm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbqb-0006jG-6z for patch@linaro.org; Sat, 20 Mar 2021 09:40:57 -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) 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-Received: by 2002:a17:906:ac6:: with SMTP id z6mr9609147ejf.505.1616247443508; Sat, 20 Mar 2021 06:37:23 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= , Li-Wen Hsu , Yonggang Luo Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- .cirrus.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/.cirrus.yml b/.cirrus.yml index bc40a0550d..f53c519447 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -3,7 +3,7 @@ env: 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-log.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=1 From patchwork Sat Mar 20 13:37:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 405440 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2191335jai; Sat, 20 Mar 2021 06:47:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvJVF10Ls+zIEijSiaKDM2tRo59oOnqU5fEUwwp3lZv5NMJSSvwQmE4gtDEGebpfRaFV+L X-Received: by 2002:a25:850e:: with SMTP id w14mr13102996ybk.259.1616248022539; Sat, 20 Mar 2021 06:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616248022; cv=none; d=google.com; s=arc-20160816; b=FqMjoSyS9tX8EJfmJCPjzAOFvJQd68vC7iRRb4ItCU+g5kaR6M8Tmky0spBO1NU0J0 7aPXb0lv+9QUi4jw8iEJMs/WyK8UWzR8GkkXypoz8OKnhBn1n0alCx0IP8/YhpDl9JlN Wkj/2UYtaR1ZIhrakl53bAgOxC9hinGU3J020P9LW6BfheNhrGDyQyUX6GZfqsj8s5+D kyOXgCcPEFCgcHwPDJQ9MiNms3nh2He/Qxznw07UE2X8ks/KGnZ/z9OwKbjBqZW/PpUj dCjHNYFPMkpQTTkyexHehRtNhhz5EGPWJiuDWiWnbyRTkprT6vLZiHp6R4rhDk0JBQpj ZrYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=TZzbS0oW3oHhvrKUDiA6aAQNFJJzORAw18XrtKz1I80=; b=NYUAZExWBpf4tccM89sApnSF02yNwxJ5ib41ef4CPmslPgJM7aj+V5+NGMYIrdJZMR E4VXZXaAYgap+pZR29yJJ6ZDXRMyXepfpGDFdmRs9x5B4MEQQTKCTX7G0X8t9A0DaOwN 5F/FDQ3/Kb/YkKNPegBUC905Mi8eaLs/NVDYAGBcTKlJ6CG3YPDqdGQkeB3U3Fmkgpes LlcbDIVriH5DkdFIDcq4CsjWkLtAPb4YWgP/UtVyGLmNmJ+3UZrd5cG7IFeYMOZlTF+d LaMMBo4nlC5z/5W3WDLmeiPUhqiaOvSGKw6PnKGqZYIZKft+PyOijyDrN/wN1IfN45yX ZdeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dMa5gNuv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n78si7936921ybf.105.2021.03.20.06.47.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Mar 2021 06:47:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dMa5gNuv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbwT-00036B-RU for patch@linaro.org; Sat, 20 Mar 2021 09:47:01 -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) 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-Received: by 2002:a05:6402:512:: with SMTP id m18mr15307217edv.372.1616247892067; Sat, 20 Mar 2021 06:44:52 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= , Thomas Huth Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- tests/unit/test-cutils.c | 117 +++++++++++++++++++++++++++++++++++++-- util/cutils.c | 4 +- 2 files changed, 114 insertions(+), 7 deletions(-) -- 2.20.1 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 = 0xbaadf00d; + uint64_t res; str = "0"; + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0); @@ -1962,6 +1964,8 @@ static void test_qemu_strtosz_simple(void) /* Leading 0 gives decimal results, not octal */ str = "08"; + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 8); @@ -1969,46 +1973,61 @@ static void test_qemu_strtosz_simple(void) /* Leading space is ignored */ str = " 12345"; + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 12345); g_assert(endptr == str + 6); + res = 0xbaadf00d; err = qemu_strtosz(str, NULL, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 12345); str = "9007199254740991"; /* 2^53-1 */ + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0x1fffffffffffff); g_assert(endptr == str + 16); str = "9007199254740992"; /* 2^53 */ + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0x20000000000000); g_assert(endptr == str + 16); str = "9007199254740993"; /* 2^53+1 */ + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0x20000000000001); g_assert(endptr == str + 16); str = "18446744073709549568"; /* 0xfffffffffffff800 (53 msbs set) */ + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0xfffffffffffff800); g_assert(endptr == str + 20); str = "18446744073709550591"; /* 0xfffffffffffffbff */ + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0xfffffffffffffbff); g_assert(endptr == str + 20); str = "18446744073709551615"; /* 0xffffffffffffffff */ + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0xffffffffffffffff); @@ -2020,21 +2039,27 @@ static void test_qemu_strtosz_hex(void) const char *str; const char *endptr; int err; - uint64_t res = 0xbaadf00d; + uint64_t res; str = "0x0"; + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0); g_assert(endptr == str + 3); str = "0xab"; + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 171); g_assert(endptr == str + 4); str = "0xae"; + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 174); @@ -2053,44 +2078,60 @@ static void test_qemu_strtosz_units(void) const char *e = "1E"; int err; const char *endptr; - uint64_t res = 0xbaadf00d; + uint64_t res; /* default is M */ + endptr = NULL; + res = 0xbaadf00d; err = qemu_strtosz_MiB(none, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, MiB); g_assert(endptr == none + 1); + endptr = NULL; + res = 0xbaadf00d; err = qemu_strtosz(b, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 1); g_assert(endptr == b + 2); + endptr = NULL; + res = 0xbaadf00d; err = qemu_strtosz(k, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, KiB); g_assert(endptr == k + 2); + endptr = NULL; + res = 0xbaadf00d; err = qemu_strtosz(m, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, MiB); g_assert(endptr == m + 2); + endptr = NULL; + res = 0xbaadf00d; err = qemu_strtosz(g, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, GiB); g_assert(endptr == g + 2); + endptr = NULL; + res = 0xbaadf00d; err = qemu_strtosz(t, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, TiB); g_assert(endptr == t + 2); + endptr = NULL; + res = 0xbaadf00d; err = qemu_strtosz(p, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, PiB); g_assert(endptr == p + 2); + endptr = NULL; + res = 0xbaadf00d; err = qemu_strtosz(e, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, EiB); @@ -2102,9 +2143,11 @@ static void test_qemu_strtosz_float(void) const char *str; int err; const char *endptr; - uint64_t res = 0xbaadf00d; + uint64_t res; str = "0.5E"; + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, EiB / 2); @@ -2112,6 +2155,8 @@ static void test_qemu_strtosz_float(void) /* For convenience, a fraction of 0 is tolerated even on bytes */ str = "1.0B"; + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 1); @@ -2119,6 +2164,8 @@ static void test_qemu_strtosz_float(void) /* An empty fraction is tolerated */ str = "1.k"; + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 1024); @@ -2126,6 +2173,8 @@ static void test_qemu_strtosz_float(void) /* For convenience, we permit values that are not byte-exact */ str = "12.345M"; + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, (uint64_t) (12.345 * MiB + 0.5)); @@ -2140,67 +2189,91 @@ static void test_qemu_strtosz_invalid(void) uint64_t res = 0xbaadf00d; str = ""; + endptr = NULL; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, -EINVAL); + g_assert_cmpint(res, ==, 0xbaadf00d); g_assert(endptr == str); str = " \t "; + endptr = NULL; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, -EINVAL); + g_assert_cmpint(res, ==, 0xbaadf00d); g_assert(endptr == str); str = "crap"; + endptr = NULL; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, -EINVAL); + g_assert_cmpint(res, ==, 0xbaadf00d); g_assert(endptr == str); str = "inf"; + endptr = NULL; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, -EINVAL); + g_assert_cmpint(res, ==, 0xbaadf00d); g_assert(endptr == str); str = "NaN"; + endptr = NULL; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, -EINVAL); + g_assert_cmpint(res, ==, 0xbaadf00d); g_assert(endptr == str); /* Fractional values require scale larger than bytes */ str = "1.1B"; + endptr = NULL; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, -EINVAL); + g_assert_cmpint(res, ==, 0xbaadf00d); g_assert(endptr == str); str = "1.1"; + endptr = NULL; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, -EINVAL); + g_assert_cmpint(res, ==, 0xbaadf00d); g_assert(endptr == str); /* No floating point exponents */ str = "1.5e1k"; + endptr = NULL; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, -EINVAL); + g_assert_cmpint(res, ==, 0xbaadf00d); g_assert(endptr == str); str = "1.5E+0k"; + endptr = NULL; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, -EINVAL); + g_assert_cmpint(res, ==, 0xbaadf00d); g_assert(endptr == str); /* No hex fractions */ str = "0x1.8k"; + endptr = NULL; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, -EINVAL); + g_assert_cmpint(res, ==, 0xbaadf00d); g_assert(endptr == str); /* No negative values */ str = "-0"; + endptr = NULL; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, -EINVAL); + g_assert_cmpint(res, ==, 0xbaadf00d); g_assert(endptr == str); str = "-1"; + endptr = NULL; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, -EINVAL); + g_assert_cmpint(res, ==, 0xbaadf00d); g_assert(endptr == str); } @@ -2209,48 +2282,72 @@ static void test_qemu_strtosz_trailing(void) const char *str; const char *endptr; int err; - uint64_t res = 0xbaadf00d; + uint64_t res; str = "123xxx"; + endptr = NULL; + res = 0xbaadf00d; err = qemu_strtosz_MiB(str, &endptr, &res); + g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 123 * MiB); g_assert(endptr == str + 3); + res = 0xbaadf00d; err = qemu_strtosz(str, NULL, &res); g_assert_cmpint(err, ==, -EINVAL); + g_assert_cmpint(res, ==, 0xbaadf00d); str = "1kiB"; + endptr = NULL; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 1024); g_assert(endptr == str + 2); + res = 0xbaadf00d; err = qemu_strtosz(str, NULL, &res); g_assert_cmpint(err, ==, -EINVAL); + g_assert_cmpint(res, ==, 0xbaadf00d); str = "0x"; + endptr = NULL; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); + g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0); g_assert(endptr == str + 1); + res = 0xbaadf00d; err = qemu_strtosz(str, NULL, &res); g_assert_cmpint(err, ==, -EINVAL); + g_assert_cmpint(res, ==, 0xbaadf00d); str = "0.NaN"; + endptr = NULL; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, 0); + g_assert_cmpint(res, ==, 0); g_assert(endptr == str + 2); + res = 0xbaadf00d; err = qemu_strtosz(str, NULL, &res); g_assert_cmpint(err, ==, -EINVAL); + g_assert_cmpint(res, ==, 0xbaadf00d); str = "123-45"; + endptr = NULL; + res = 0xbaadf00d; err = qemu_strtosz(str, &endptr, &res); + g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 123); g_assert(endptr == str + 3); + res = 0xbaadf00d; err = qemu_strtosz(str, NULL, &res); g_assert_cmpint(err, ==, -EINVAL); + g_assert_cmpint(res, ==, 0xbaadf00d); } static void test_qemu_strtosz_erange(void) @@ -2261,13 +2358,17 @@ static void test_qemu_strtosz_erange(void) uint64_t res = 0xbaadf00d; str = "18446744073709551616"; /* 2^64; see strtosz_simple for 2^64-1 */ + endptr = NULL; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, -ERANGE); + g_assert_cmpint(res, ==, 0xbaadf00d); g_assert(endptr == str + 20); str = "20E"; + endptr = NULL; err = qemu_strtosz(str, &endptr, &res); g_assert_cmpint(err, ==, -ERANGE); + g_assert_cmpint(res, ==, 0xbaadf00d); g_assert(endptr == str + 3); } @@ -2276,15 +2377,19 @@ static void test_qemu_strtosz_metric(void) const char *str; int err; const char *endptr; - uint64_t res = 0xbaadf00d; + uint64_t res; str = "12345k"; + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz_metric(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 12345000); g_assert(endptr == str + 6); str = "12.345M"; + endptr = str; + res = 0xbaadf00d; err = qemu_strtosz_metric(str, &endptr, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 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 **end, } } - *result = val; retval = 0; out: @@ -371,6 +370,9 @@ out: } else if (*endptr) { retval = -EINVAL; } + if (retval == 0) { + *result = val; + } return retval; } From patchwork Sat Mar 20 13:37:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 405443 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2192724jai; Sat, 20 Mar 2021 06:49:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoPAySwGfzto4B9+FU1jnexwm7QIqOmkVrZRg7TaVoA4lj3OUz6LprXQL8KozqONtxXhb1 X-Received: by 2002:a25:c2c4:: with SMTP id s187mr13280344ybf.292.1616248187671; Sat, 20 Mar 2021 06:49:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616248187; cv=none; d=google.com; s=arc-20160816; b=DedUSXmXX14A+caUHXOI9pNAVR5C2ZOnLx+khpxxqaCleDJBSyVd5zNMF8i0+AqGIK FCQq8LyFIdJYJ/3p6H2LCjpyoP3YMXcflLQ2Vhaxbktv8JtkG52TgGuDvIhyZG49zeD3 oNNRqTlrr+VtlzRKZl7ZPg4wjTE2xwYnqXz1xOo0tFvT7rs5essenbLiAo9zfCo1ev9q w1trlWmllLGATNoyewSHUbIVNNDoy+U7neVhQuulHWiI70HenLA+/CaM5pBf5mek5jIb CpeLAxXQuppyOYQZSFg83VGf83T/l1U/zetC+HG/r3zKyUVsURpW8z8kxmPCq0yVmwfU lI3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=uL96Uis9yF2paA0n5GhgWk7dCyVBjyOpNhr7RDd2Ljw=; b=M34GweOBymjhGyeUfizKKyA1CS+cvgUpYmkYYxI+Ed3TW4C8Ygv95dpQa3gCj2jmE/ gQpSJOFK2f6vj2nHC+C1h97GJjKXc/R8Kot47jauPcmEsLSKw+qH6GXUqoabd3wXtq39 WMROmDMj1Eskwg5tZXT3Vd8R3rghYGuvj6BQYjEEuOFHmpc5K4DG3UJnHdeXSmn6FFoW LUWIFa9H+W0r1ffADsa7MoSrK1JT8O3zvqfZnRbFJJJE+7YII/OntvgbWPYrAnADLBAm SfuTiGsKow0J/N0/ZPG1qN3R36cDde9yWdrQw04Gup0aY9p9yswMd+KXZnxlDbF+lAWD +tdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vNgvsdRZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x17si8148011ybj.139.2021.03.20.06.49.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Mar 2021 06:49:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vNgvsdRZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNbz8-0007Ye-Qs for patch@linaro.org; Sat, 20 Mar 2021 09:49:46 -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) 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-Received: by 2002:a17:906:9152:: with SMTP id y18mr9872282ejw.19.1616247891424; Sat, 20 Mar 2021 06:44:51 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= , Thomas Huth Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- tests/unit/test-cutils.c | 54 ++++++++++++++++++++++++++++++++++++++++ util/cutils.c | 29 +++++++++++++++------ 2 files changed, 75 insertions(+), 8 deletions(-) -- 2.20.1 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, ==, 0); g_assert_cmpint(res, ==, 0x123); g_assert(endptr == str + strlen(str)); + + str = "0x"; + res = 999; + endptr = &f; + err = qemu_strtoi(str, &endptr, 16, &res); + + g_assert_cmpint(err, ==, 0); + g_assert_cmpint(res, ==, 0); + g_assert(endptr == str + 1); } static void test_qemu_strtoi_max(void) @@ -669,6 +678,15 @@ static void test_qemu_strtoui_hex(void) g_assert_cmpint(err, ==, 0); g_assert_cmphex(res, ==, 0x123); g_assert(endptr == str + strlen(str)); + + str = "0x"; + res = 999; + endptr = &f; + err = qemu_strtoui(str, &endptr, 16, &res); + + g_assert_cmpint(err, ==, 0); + g_assert_cmphex(res, ==, 0); + g_assert(endptr == str + 1); } static void test_qemu_strtoui_max(void) @@ -955,6 +973,15 @@ static void test_qemu_strtol_hex(void) g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0x123); g_assert(endptr == str + strlen(str)); + + str = "0x"; + res = 999; + endptr = &f; + err = qemu_strtol(str, &endptr, 16, &res); + + g_assert_cmpint(err, ==, 0); + g_assert_cmpint(res, ==, 0); + g_assert(endptr == str + 1); } static void test_qemu_strtol_max(void) @@ -1244,6 +1271,15 @@ static void test_qemu_strtoul_hex(void) g_assert_cmpint(err, ==, 0); g_assert_cmphex(res, ==, 0x123); g_assert(endptr == str + strlen(str)); + + str = "0x"; + res = 999; + endptr = &f; + err = qemu_strtoul(str, &endptr, 16, &res); + + g_assert_cmpint(err, ==, 0); + g_assert_cmphex(res, ==, 0); + g_assert(endptr == str + 1); } static void test_qemu_strtoul_max(void) @@ -1528,6 +1564,15 @@ static void test_qemu_strtoi64_hex(void) g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0x123); g_assert(endptr == str + strlen(str)); + + str = "0x"; + endptr = &f; + res = 999; + err = qemu_strtoi64(str, &endptr, 16, &res); + + g_assert_cmpint(err, ==, 0); + g_assert_cmpint(res, ==, 0); + g_assert(endptr == str + 1); } static void test_qemu_strtoi64_max(void) @@ -1815,6 +1860,15 @@ static void test_qemu_strtou64_hex(void) g_assert_cmpint(err, ==, 0); g_assert_cmphex(res, ==, 0x123); g_assert(endptr == str + strlen(str)); + + str = "0x"; + endptr = &f; + res = 999; + err = qemu_strtou64(str, &endptr, 16, &res); + + g_assert_cmpint(err, ==, 0); + g_assert_cmphex(res, ==, 0); + g_assert(endptr == str + 1); } 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 >= nptr); + + /* Windows has a bug in that it fails to parse 0 from "0x" in base 16 */ + if (check_zero && ep == nptr && libc_errno == 0) { + char *tmp; + + errno = 0; + if (strtol(nptr, &tmp, 10) == 0 && errno == 0 && + (*tmp == 'x' || *tmp == 'X')) { + ep = tmp; + } + } + if (endptr) { *endptr = ep; } @@ -465,7 +478,7 @@ int qemu_strtoi(const char *nptr, const char **endptr, int base, } else { *result = lresult; } - return check_strtox_error(nptr, ep, endptr, errno); + return check_strtox_error(nptr, ep, endptr, lresult == 0, errno); } /** @@ -524,7 +537,7 @@ int qemu_strtoui(const char *nptr, const char **endptr, int base, *result = lresult; } } - return check_strtox_error(nptr, ep, endptr, errno); + return check_strtox_error(nptr, ep, endptr, lresult == 0, errno); } /** @@ -566,7 +579,7 @@ int qemu_strtol(const char *nptr, const char **endptr, int base, errno = 0; *result = strtol(nptr, &ep, base); - return check_strtox_error(nptr, ep, endptr, errno); + return check_strtox_error(nptr, ep, endptr, *result == 0, errno); } /** @@ -613,7 +626,7 @@ int qemu_strtoul(const char *nptr, const char **endptr, int base, if (errno == ERANGE) { *result = -1; } - return check_strtox_error(nptr, ep, endptr, errno); + return check_strtox_error(nptr, ep, endptr, *result == 0, errno); } /** @@ -639,7 +652,7 @@ int qemu_strtoi64(const char *nptr, const char **endptr, int base, QEMU_BUILD_BUG_ON(sizeof(int64_t) != sizeof(long long)); errno = 0; *result = strtoll(nptr, &ep, base); - return check_strtox_error(nptr, ep, endptr, errno); + return check_strtox_error(nptr, ep, endptr, *result == 0, errno); } /** @@ -668,7 +681,7 @@ int qemu_strtou64(const char *nptr, const char **endptr, int base, if (errno == ERANGE) { *result = -1; } - return check_strtox_error(nptr, ep, endptr, errno); + return check_strtox_error(nptr, ep, endptr, *result == 0, errno); } /** @@ -708,7 +721,7 @@ int qemu_strtod(const char *nptr, const char **endptr, double *result) errno = 0; *result = strtod(nptr, &ep); - return check_strtox_error(nptr, ep, endptr, errno); + return check_strtox_error(nptr, ep, endptr, false, errno); } /**