From patchwork Mon Mar 7 16:46:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548867 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1091274wrl; Mon, 7 Mar 2022 08:48:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJweIHhf+JSII4zatoLscO1R7vOM1nbq2K3TWNIfqq7cJNp1VgrRjcj4QHhn98ma3CX17WRE X-Received: by 2002:a81:1512:0:b0:2dc:75df:f3a2 with SMTP id 18-20020a811512000000b002dc75dff3a2mr9090622ywv.139.1646671703291; Mon, 07 Mar 2022 08:48:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646671703; cv=none; d=google.com; s=arc-20160816; b=ne6n24N+aGRgAN+OiBghOd+FHDxAopIbmeHTYIUvvbfVHWqUS7zsS9J69mBPwzOM20 n0EU1rCYinn+EMPFbaUm1Gtl0yUehjGbdSim0ynw6X+uDdkK8T809jLaSzJgLVzhR1Fa Za93hn0WR1Bsdc3/8GDcg1jqNwxneS1aZD7thVXR9LlkqX7ciKW0Yz6lZUG6DQ2zQLYw ceMquQFw/lTma97TBiL0OS/mbDnrWzPm0iYY2Fv1t/WbFHseBxrL9536kmUjLDXqaJHK dDEzUFWAUiH+dcJtn2LH8LVzylMYNqtptPXuqXiv2jB59LKyrsilLLqKBKaUuaXtQoZj /NuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=khb2dSFPApkPaahIP5O1Jg4lPgEuKg6KdJgWB44Ysm4=; b=fm8cFVz3JemORyXUtAMwRmjzl8WJL3He49Pu3Vt5EoDrQ6Jk2y8NLlMm7IlRT9xNqU LFvfeH62k0Fpt5VQ8GvejY5v85aW39bkA73JB8X1KAzQm6D4JHXi//yxM8YMPxR+eYxT cL7qF7W9Bp/nAaCHdSP22LLhNHreoyDdVNClpEmLa6cMpLf1Mp1nk9khXC3qrGV9+7nW eKuK28GTKUOusCE01YV882/HDhrL6kTku2GlHS7wOqJUv+5BtEDxGPNTOsu6P1a7URjS N2CTd1+gRDsD8aEsTcrOTFtE2VtwvJuT1+fQTnFdHJEoQBEVebkA/aD6udV8QUyQxBtl wUTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mOzqoQYN; 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 bc13-20020a05690c000d00b002d035ccf969si11983173ywb.13.2022.03.07.08.48.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:48:23 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mOzqoQYN; 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]:60498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGX0-0001LF-O0 for patch@linaro.org; Mon, 07 Mar 2022 11:48:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGVv-0001Kw-RH for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:15 -0500 Received: from [2a00:1450:4864:20::429] (port=37874 helo=mail-wr1-x429.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGVu-0007il-9K for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:15 -0500 Received: by mail-wr1-x429.google.com with SMTP id q14so8727891wrc.4 for ; Mon, 07 Mar 2022 08:47:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=khb2dSFPApkPaahIP5O1Jg4lPgEuKg6KdJgWB44Ysm4=; b=mOzqoQYNMgc1nA+71FFmo27RsIKW294IW0QHrhL0EAbzL9K08ZjeIofxkiChLbJdh8 szVPjBkIjgzs3wQJjJZGa5CMBpnUmlcER8clYcBzTUdek7WjhFXBYEwv4p+VETkgarX6 b+hRC7EJyCuJwsEFAOUG+Vxms2VJewM9X42vq5rZn1Fnps4UfhP8H4Q7imuzmsa9Z3HM gCrKLIgKG/fdqSYEai6A63uCN/XVnsh1zZJFuEVpCJSDkoAmEOuCXxe+XyBCeq+AEsjf JLRybn0lRGuR0ubhkY35dV00VbHkS8B07fYNBq/k3mQhfhIS3kyhlJjKymy/+qGViWC9 abNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=khb2dSFPApkPaahIP5O1Jg4lPgEuKg6KdJgWB44Ysm4=; b=i7mev0D5nd5eseQGSqJte/+ZqWza7k+UyGWBzpqwFJ00xQFcn1lx9J+K6gP3olNEM+ ReLRyWm0hAs+6MZ00EBuWAH7iLbzZgGGvZJE3xpUePPSGcH5qH8JGh2NqBV5jel7h5Fe r0roYAJK+kGkO0tGUeAEso7Gvd/JXNi1g8hijBJqXHdDmF84zoSDddCJOXTmT43ZJ38+ LSpqZe1Z8tCcaYRYmANzrrYguQuM3CmVtuFoHerYmToWdd815Gn2zMdfCseTHyxxtMDB dO5epTYveuBdrQoPBSi3m/RmbUNJuGw9JL7/ElFZpcX0J4yPRcGVcf4mf/D4rAEHlPzR 5qbw== X-Gm-Message-State: AOAM531rZrcxfj8JQHo83Ee1rSB7GulTpeOzzbOnTuzG4MUoFStaruFY sp+CMEzXqz3+sBreU4uTG+s08EcGLTnK7A== X-Received: by 2002:a5d:6f0d:0:b0:1f1:f897:9dc with SMTP id ay13-20020a5d6f0d000000b001f1f89709dcmr4229874wrb.32.1646671632741; Mon, 07 Mar 2022 08:47:12 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:12 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 01/18] util: Make qemu_oom_check() a static function Date: Mon, 7 Mar 2022 16:46:52 +0000 Message-Id: <20220307164709.2503250-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::429 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The qemu_oom_check() function, which we define in both oslib-posix.c and oslib-win32.c, is now used only locally in that file; make it static. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-id: 20220226180723.1706285-3-peter.maydell@linaro.org --- include/qemu-common.h | 2 -- util/oslib-posix.c | 2 +- util/oslib-win32.c | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/qemu-common.h b/include/qemu-common.h index 68b2e3bc109..8c0d9ab0f77 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -26,8 +26,6 @@ int qemu_main(int argc, char **argv, char **envp); #endif -void *qemu_oom_check(void *ptr); - ssize_t qemu_write_full(int fd, const void *buf, size_t count) QEMU_WARN_UNUSED_RESULT; diff --git a/util/oslib-posix.c b/util/oslib-posix.c index f2be7321c59..ed5974d3845 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -199,7 +199,7 @@ fail_close: return false; } -void *qemu_oom_check(void *ptr) +static void *qemu_oom_check(void *ptr) { if (ptr == NULL) { fprintf(stderr, "Failed to allocate memory: %s\n", strerror(errno)); diff --git a/util/oslib-win32.c b/util/oslib-win32.c index af559ef3398..c87e6977246 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -44,7 +44,7 @@ /* this must come after including "trace.h" */ #include -void *qemu_oom_check(void *ptr) +static void *qemu_oom_check(void *ptr) { if (ptr == NULL) { fprintf(stderr, "Failed to allocate memory: %lu\n", GetLastError()); From patchwork Mon Mar 7 16:46:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548871 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1092253wrl; Mon, 7 Mar 2022 08:49:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwYpWwPV2Nla10Zg8DLBXVLAjxUWeYkp4QpdxpohdcCTV5s5cGDkojKds0/pkF69riHqOXN X-Received: by 2002:a81:4cc9:0:b0:2d8:20d5:eb2f with SMTP id z192-20020a814cc9000000b002d820d5eb2fmr8897627ywa.107.1646671794195; Mon, 07 Mar 2022 08:49:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646671794; cv=none; d=google.com; s=arc-20160816; b=Rq9TBSoWyRtvCknck54SavCikdVaO2erbL+CAS0FChbtVO6nXuqGg9R58R/iaIYpfo DGMIdGvhFCGakV/L0k5xgyQS7Tjs8QA7J81rmVGOGTn/eqaoMQfZol4Jdl7d1TPIo270 2U+jRbFjOgx7JY+mjo0j8ZpuG+Jc0elhtgHvlOruqbRSTI9Q8qBnneT/8SLbEXwGds9e qLnzZ3KT8qBVZtzzyOXezSdJuLqpvt1ZfL0SoSYPRSEZ5c/l2iHVHu5iC20hcTKk83ui dWFe88e3sEQ4elFzNuGNbbeSYKMkLwzfV08TRNWy2S8YkliO1P92dHckIBuqWJrNMjKG p//g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=9VfQ5wi2gw0vpXzXf74eUVOgttIcr7mfX30dEcsQ3oM=; b=FRUkXJTi31eZDDlImFKJIkFEM4Fx3gBOxNYdsuX3rUA7mCRyuWEntdrcXjaFur3o78 vZI/nHbPdqEYhV52HozXq1GzY2xP1/RMS2vSR4yc+iO30VPvi1avNPEnYB4zrY/dloBs oeJi2Ry5w7dvpS52+qolv1bCgTqC+FjPJoTLlZeCoxcMhoJKxJxZEf1+kUFhO2hZj2DB vdHcs47c9VIT2lb0IiXrlLOfsVNa4fNGgGf/AI1Tr260DDkRN6zPpSdCzTP7Osuc8hQd bqaorV/I6n1m9nY830ZIz0O/an7qqzKaQjECn+Vic9wcsxHn6rdAVuselQc3VujKjAZM MM6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S7gZrJQ4; 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 t135-20020a81788d000000b002d0718d922fsi8647707ywc.248.2022.03.07.08.49.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:49:54 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S7gZrJQ4; 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]:40386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGYS-0006gC-4p for patch@linaro.org; Mon, 07 Mar 2022 11:49:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGVx-0001MH-3R for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:17 -0500 Received: from [2a00:1450:4864:20::436] (port=41979 helo=mail-wr1-x436.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGVu-0007is-UT for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:16 -0500 Received: by mail-wr1-x436.google.com with SMTP id i8so24261541wrr.8 for ; Mon, 07 Mar 2022 08:47:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9VfQ5wi2gw0vpXzXf74eUVOgttIcr7mfX30dEcsQ3oM=; b=S7gZrJQ4mYMIduPfWXEFFEcAhjU1yxS4OLf9eRBpw6cSxvF4PdAslKPU3P8Q1f7/+f /PcrmSI+BGPCceHc7Xe828ZIbLLbZYLukvMil0igPaBE7kHxjElcp80MMlHNxCA4HLGe AyuRnaz9MmJzioqwILRzBW0Ws15bVc78LwAZAvQ93nMqhv3f5stCtJMGef4C8/ivd6Pz G6w34/Mpq/agOTrZ87sPo5J3oLJpbjxdyefmn6//E5pf050pRFYOng+i0W1mPWSRxdQ0 DNU1UIFA81Ek/bwzbfEJA0hspadT764TVlQ0wfP89OProfw6wgAyHpRj9AjC5QGA1KXj gP0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9VfQ5wi2gw0vpXzXf74eUVOgttIcr7mfX30dEcsQ3oM=; b=5EPs/UXrg+LDy9IoOEfSmyOM5XhbA1IU2aAGSb07s+a55QEpNdwyKFPZBSao2i4At6 9oCkzhiEKMtteY/KLTsw9dqumByyN4nteIdc8pRlk9x1/VH3f6aGr37eZVtDNvGVpP8G mmpJJODfvFGMY6dJB97NCnXiUXdT+gwOj2lqOsU90eC6h3kXRk4j2ZM1c8P7Jv5c1z9j DUkvwBZ1JJ4/bzzyJrQKNpoDtBcBNYqrMPwBcCub3cJ+pONXfHE56FNQsAjrtPy+DmrX 6w8HITDAt3Mzmog6jocmuYDqXg+H9dmpCqblRRQAsreKi+522ZrB+0amj5d19YNju/qd NIdA== X-Gm-Message-State: AOAM532D71V8xt4yb/gNi/DQJIf8/IlaIQCtNxNKDFBqt8jWPIqm6CpR xnr1Ab9PPDJ+ne7MoNnVsYvjzCQWEcaqZw== X-Received: by 2002:a5d:5911:0:b0:1f0:3272:2ac9 with SMTP id v17-20020a5d5911000000b001f032722ac9mr8751180wrd.1.1646671633620; Mon, 07 Mar 2022 08:47:13 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:13 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/18] util: Unify implementations of qemu_memalign() Date: Mon, 7 Mar 2022 16:46:53 +0000 Message-Id: <20220307164709.2503250-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::436 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We implement qemu_memalign() in both oslib-posix.c and oslib-win32.c, but the two versions are essentially the same: they call qemu_try_memalign(), and abort() after printing an error message if it fails. The only difference is that the win32 version prints the GetLastError() value whereas the POSIX version prints strerror(errno). However, this is a bug in the win32 version: in commit dfbd0b873a85021 in 2020 we changed the implementation of qemu_try_memalign() from using VirtualAlloc() (which sets the GetLastError() value) to using _aligned_malloc() (which sets errno), but didn't update the error message to match. Replace the two separate functions with a single version in a new memalign.c file, which drops the unnecessary extra qemu_oom_check() function and instead prints a more useful message including the requested size and alignment as well as the errno string. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20220226180723.1706285-4-peter.maydell@linaro.org Reviewed-by: Philippe Mathieu-Daudé --- util/memalign.c | 39 +++++++++++++++++++++++++++++++++++++++ util/oslib-posix.c | 14 -------------- util/oslib-win32.c | 14 -------------- util/meson.build | 1 + 4 files changed, 40 insertions(+), 28 deletions(-) create mode 100644 util/memalign.c diff --git a/util/memalign.c b/util/memalign.c new file mode 100644 index 00000000000..6dfc20abbb1 --- /dev/null +++ b/util/memalign.c @@ -0,0 +1,39 @@ +/* + * memalign.c: Allocate an aligned memory region + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2010-2016 Red Hat, Inc. + * Copyright (c) 2022 Linaro Ltd + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" + +void *qemu_memalign(size_t alignment, size_t size) +{ + void *p = qemu_try_memalign(alignment, size); + if (p) { + return p; + } + fprintf(stderr, + "qemu_memalign: failed to allocate %zu bytes at alignment %zu: %s\n", + size, alignment, strerror(errno)); + abort(); +} diff --git a/util/oslib-posix.c b/util/oslib-posix.c index ed5974d3845..0278902ee79 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -199,15 +199,6 @@ fail_close: return false; } -static void *qemu_oom_check(void *ptr) -{ - if (ptr == NULL) { - fprintf(stderr, "Failed to allocate memory: %s\n", strerror(errno)); - abort(); - } - return ptr; -} - void *qemu_try_memalign(size_t alignment, size_t size) { void *ptr; @@ -234,11 +225,6 @@ void *qemu_try_memalign(size_t alignment, size_t size) return ptr; } -void *qemu_memalign(size_t alignment, size_t size) -{ - return qemu_oom_check(qemu_try_memalign(alignment, size)); -} - /* alloc shared memory pages */ void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment, bool shared, bool noreserve) diff --git a/util/oslib-win32.c b/util/oslib-win32.c index c87e6977246..05857414695 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -44,15 +44,6 @@ /* this must come after including "trace.h" */ #include -static void *qemu_oom_check(void *ptr) -{ - if (ptr == NULL) { - fprintf(stderr, "Failed to allocate memory: %lu\n", GetLastError()); - abort(); - } - return ptr; -} - void *qemu_try_memalign(size_t alignment, size_t size) { void *ptr; @@ -68,11 +59,6 @@ void *qemu_try_memalign(size_t alignment, size_t size) return ptr; } -void *qemu_memalign(size_t alignment, size_t size) -{ - return qemu_oom_check(qemu_try_memalign(alignment, size)); -} - static int get_allocation_granularity(void) { SYSTEM_INFO system_info; diff --git a/util/meson.build b/util/meson.build index 3736988b9f6..f6ee74ad0c8 100644 --- a/util/meson.build +++ b/util/meson.build @@ -51,6 +51,7 @@ util_ss.add(when: 'CONFIG_POSIX', if_true: files('drm.c')) util_ss.add(files('guest-random.c')) util_ss.add(files('yank.c')) util_ss.add(files('int128.c')) +util_ss.add(files('memalign.c')) if have_user util_ss.add(files('selfmap.c')) From patchwork Mon Mar 7 16:46:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548874 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1094010wrl; Mon, 7 Mar 2022 08:52:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgnK2RIO8VsUz1gXWb0GrYJIQiH2t6lYBDx8JOQQaTtowWwZWsmo7P8jIi8TPIbBExKLJC X-Received: by 2002:a81:e0b:0:b0:2ca:287c:6be1 with SMTP id 11-20020a810e0b000000b002ca287c6be1mr9247655ywo.134.1646671972525; Mon, 07 Mar 2022 08:52:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646671972; cv=none; d=google.com; s=arc-20160816; b=0Er6wS3dZv3sfSjmro6P5iBJXlA5voweSKnINeob5MjIS7YSj/BlhUM/r75VFQardO FNmfWZpOjShMRPou5wfRCOg70LFRJ5GTbH4BOS0oJUckSYfexHCe+feh71dSy1I5EmqR tzNRVYGt1CWhfQkDtZ2Y7pDhbnQw6DYhFeAdiTkTWRKUAlEYxjV4ndtxxfySrMiv6vZT 4kxb/2VYmH+vBjUvfH9u4AXANEF5e/c9ZhO3+qtKarQ/d8GglLIPFzi+xnaE5jLbR2Rr fGEpnDFdDJPNo5oGFonG/NitnfGxba4/M4nY3h/MmkQvq2MXwyJBQMU3Uxq6svS8m9kz pdOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=wNLlmiJKgcgevH7l2nRJUQn8/Ms/TerlHklY+uOxLsA=; b=a53geF9thFoTOKgMPOUszkedSPAngIfHZKzakaMnCO8dMD/izWa+FDlRHN2J5cN5U8 AEhmlsO2dsj0hApNgdIVSRcLNdYKgpcyJpplmBeTtoXB9/MDgXZ4kC1C9Si51Vlu29rW xXfkSVKkxP4YN33E+MNYue4xZNb6PMWiOTRRVeORhUkQWp0Syaei+0XK1pY6mkj6LMTJ OCzoT2io2T9Oxh65ncyglFVq4LO2Q3TPgovO65/+3Zm1pUyzzSN9x9gdIYxPsp85RgHn BwjzecCC3vNsLAwe93ZLOcOVa0PNznwOq+MeADfvbN8OpgkHx/gTMnoWbKdyuawbI2rk 4g4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xTyjjVL2; 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 g67-20020a813946000000b002d035ccf9cfsi7890390ywa.115.2022.03.07.08.52.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:52:52 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xTyjjVL2; 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]:48532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGbL-0003ha-VT for patch@linaro.org; Mon, 07 Mar 2022 11:52:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGVx-0001N2-H9 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:17 -0500 Received: from [2a00:1450:4864:20::42d] (port=39515 helo=mail-wr1-x42d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGVv-0007iz-Qv for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:17 -0500 Received: by mail-wr1-x42d.google.com with SMTP id n15so10165596wra.6 for ; Mon, 07 Mar 2022 08:47:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=wNLlmiJKgcgevH7l2nRJUQn8/Ms/TerlHklY+uOxLsA=; b=xTyjjVL2OXeg6EXRwId/5u2w32ZmV6gDAzGVwLT/AKmz4mcTs608VSAqj0yAeczzUc K4nGm7aHCDGHZOiPlc38ZXUFMco9IOjpsUy9J1evcJ8VWFZBusSi2jc6k/EVzMp3gUE4 mGT+vZW50G38wefn7vvcv78q0AmzD7g0RFh/E5Am2Mbfr2leCOogZ7sf9XL3RIy5TCi6 HofSJdoCHwXWN/FGsD+DY3DYBOIByevQ1h+Ky3qRnCcxwFwfX1tNuvOoqLuehyc73vMd esIQ7153KkeRMJcBY/y/kA0StG9GhLBxGMCKmux4Dgq59Kc7GpEiKMYXuYhzsu3XAFWH K5gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wNLlmiJKgcgevH7l2nRJUQn8/Ms/TerlHklY+uOxLsA=; b=uLnQUqg87uNdRqRVdf4+ChFf8j1JF/TF85pmUUL/+JhUgqlNIfULQE2VUB+fts9+p9 ZCtGHiATM34rFYF4cYJvKH2KfP9pWkLgWbO1dME/vC37I9DX/RYtHCTJ/RRdsO0G2TI3 Zqp4WW/zH/Wsj4Q/J55Q2LeSoCUWZ2k5D+9xVe3P0BtjVBokOe4DLAyRBPZKfWiMVbdH W8htKSO2O1t/9NFUaTqZUOyycKISMfOhKqQhCJAj7D7D5QCAWxVk1S0lKu+XnMjR3j/T MAvc0KL10yYvDK4ojSDLx/vxjsOxU++KknAZ2zZtu2VRfgGM+rEs0qPLbyEHzqPfShFL /mmQ== X-Gm-Message-State: AOAM533PtyegshhGmt2tl1gGN2Caim2yx3aKJ3cWyaVyzVQ6EOvWJ+ei Vhki7P4qW2B2hlGomGqo6dz6rCE8bqN9Mw== X-Received: by 2002:a05:6000:15cb:b0:1f1:e283:fcc0 with SMTP id y11-20020a05600015cb00b001f1e283fcc0mr8029596wry.18.1646671634444; Mon, 07 Mar 2022 08:47:14 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:14 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 03/18] util: Return valid allocation for qemu_try_memalign() with zero size Date: Mon, 7 Mar 2022 16:46:54 +0000 Message-Id: <20220307164709.2503250-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42d (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Currently qemu_try_memalign()'s behaviour if asked to allocate 0 bytes is rather variable: * on Windows, we will assert * on POSIX platforms, we get the underlying behaviour of the posix_memalign() or equivalent function, which may be either "return a valid non-NULL pointer" or "return NULL" Explictly check for 0 byte allocations, so we get consistent behaviour across platforms. We handle them by incrementing the size so that we return a valid non-NULL pointer that can later be passed to qemu_vfree(). This is permitted behaviour for the posix_memalign() API and is the most usual way that underlying malloc() etc implementations handle a zero-sized allocation request, because it won't trip up calling code that assumes NULL means an error. (This includes our own qemu_memalign(), which will abort on NULL.) This change is a preparation for sharing the qemu_try_memalign() code between Windows and POSIX. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- util/oslib-posix.c | 3 +++ util/oslib-win32.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 0278902ee79..f7e22f4ff9b 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -209,6 +209,9 @@ void *qemu_try_memalign(size_t alignment, size_t size) g_assert(is_power_of_2(alignment)); } + if (size == 0) { + size++; + } #if defined(CONFIG_POSIX_MEMALIGN) int ret; ret = posix_memalign(&ptr, alignment, size); diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 05857414695..8c28d70904d 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -48,12 +48,14 @@ void *qemu_try_memalign(size_t alignment, size_t size) { void *ptr; - g_assert(size != 0); if (alignment < sizeof(void *)) { alignment = sizeof(void *); } else { g_assert(is_power_of_2(alignment)); } + if (size == 0) { + size++; + } ptr = _aligned_malloc(size, alignment); trace_qemu_memalign(alignment, size, ptr); return ptr; From patchwork Mon Mar 7 16:46:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548872 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1092316wrl; Mon, 7 Mar 2022 08:50:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVPqz6Ipm8yOL9t9iiY1W2vwsvsbPrREHgx+D58nzNhw3LPm76+xw7FZV2tccIyhEDLNkM X-Received: by 2002:a25:4dd7:0:b0:621:a740:3988 with SMTP id a206-20020a254dd7000000b00621a7403988mr8933529ybb.58.1646671797089; Mon, 07 Mar 2022 08:49:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646671797; cv=none; d=google.com; s=arc-20160816; b=nk2H+gtMRNk8CIu9KkbI0ziYDtkOI1rkUaK3g0ibvl+HwOzU5l0/f6xN7tX/ENPAQ9 YdYEM9Z0tuVMn7dNYsCJuu7L5aot5j/soY5Ndn0GGSDIbkefa1mj4tALRtKo9V00t1cY kqeNJqS67IVxlO/E8sGp9D8WXKF4jIMHB5LeyIcObgleQVdouKvUTmrClfdfAO2ikWIV Tb9gKHSydyOVZ8hsRRrvXNSfIm75c47ML8aAJx/kTXZOywf1RJzyaHErVKFY6vnwESBX qp7HMjvxCD2GQnTYy2Dw7tDOdp69ciropwX7VjLfYq7xVIT7rnf8XBvP5+vDQze1CaQF uadw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=xpC06DHhxVDLscz6Xo2CkegCEhzKYUxBYFFVOWGgdvk=; b=nK1iXeLq+gzz7fhmGYhH4H1rfhJTKYzssRrxEsJ/U8HPI9ywh8yDMEKmljOF7W+pEs gaxu53AuUyg66Pta7vKJdZGcf6Ug2diea36hIt3B+OJjFY5y9euH+JxBA4vgNy8ebl/j hfq7jcGtzLR4Xcn4CH1oME6ePFOpk9Eij/6IwNhyTIcu8ZlJvzzDNxqiwNVRWCsNuzG8 fFsg3ARtkBkpLaJ89PZee6/kKgRzPJt6LypcNLExLplg/p87D0E9eKUiwhRQcB5PWdg9 Ww0nt02JGrQr5y7HvpoIGKL0o1+BTo6KMwePtZin7GaQK2RtKY5rdp5TeBd0QA4udnpc 4oCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SIqeN4At; 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 z14-20020a5b0e8e000000b0062894ce39a9si7991282ybr.195.2022.03.07.08.49.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:49:57 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SIqeN4At; 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]:40520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGYV-0006lf-Ly for patch@linaro.org; Mon, 07 Mar 2022 11:49:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGVy-0001QQ-Db for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:18 -0500 Received: from [2a00:1450:4864:20::431] (port=33631 helo=mail-wr1-x431.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGVw-0007jF-Ks for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:18 -0500 Received: by mail-wr1-x431.google.com with SMTP id j17so24366977wrc.0 for ; Mon, 07 Mar 2022 08:47:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=xpC06DHhxVDLscz6Xo2CkegCEhzKYUxBYFFVOWGgdvk=; b=SIqeN4AtLpG9QCpuK4KlXzRTsmeuUtwHAJ6m5pZMNg/XPLrpK6p7G2BkS6MsYsIHso S+/2NuSTbjQ2PPEg3Bv1JxgpR+G36OReOaV/fN6GLwR3LGcSWoeuMUlSGO8WeXky1QNG f9OojReDk8Z5KMd+0ZcuwBtPD0yR8VXexKXLCYvYvOB4g8vMCl6iEB5Hh2XDPuftoWk4 TN4IKmh3BRHulQ+uIRiTv+YgA+/h1dLJojTAyGHCbkXA8W02/fW4MDwmBxJN8bJ98Kuy A8g3v+jQvLhIFCJ4nRGKwWSdH2DbYqHjM4362bmLzASgDhh4CtYv4Lg1/hgI1P34hDqj +upw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xpC06DHhxVDLscz6Xo2CkegCEhzKYUxBYFFVOWGgdvk=; b=CboB/6hH3jH0eK6wygrIGkiRsnyHCB8ChNYDdPrzZ6rKlIEjDw61A52uJWY19cE7rP l1iHOm6LaeUQlNQaBZudL9O4L6/q0aN2wVW7o6yi+CsSgWjkE2lCoAfcUUYpZhjv0SIf yhLG56oJ4t1uwGCJlpGydO8TAXFai86ZN32Clam/pu+GzgHshhch1xCkj9D3Sgi9rftw r7b7AFiBeLjA7U/MfIcfRVXIaroJ56iWCcUxyWlLH5u9ncLVjl6HrWy156QMVZSIgNEY zZOlA+UX0iRIDfDCk0fpS9+zamW4cLlVD0ABgoFF5et56CGY88xubl0Ng2lH/PUu8x0i mtSQ== X-Gm-Message-State: AOAM533TpExL7ayCcS3t3tqhp2CxBmlF5EdtcfXrt89DgegwrBD90sXL GnGdvoj0ztDQiLMdj1m/I0fW1RQvP/Fj5A== X-Received: by 2002:adf:f1c1:0:b0:1e3:1381:7bd5 with SMTP id z1-20020adff1c1000000b001e313817bd5mr9076519wro.450.1646671635234; Mon, 07 Mar 2022 08:47:15 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:14 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 04/18] meson.build: Don't misdetect posix_memalign() on Windows Date: Mon, 7 Mar 2022 16:46:55 +0000 Message-Id: <20220307164709.2503250-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::431 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Currently we incorrectly think that posix_memalign() exists on Windows. This is because of a combination of: * the msys2/mingw toolchain/libc claim to have a __builtin_posix_memalign when there isn't a builtin of that name * meson will assume that if you have a __builtin_foo that counts for has_function('foo') Specifying a specific include file via prefix: causes meson to not treat builtins as sufficient and actually look for the function itself; see this meson pull request which added that as the official way to get the right answer: https://github.com/mesonbuild/meson/pull/1150 Currently this misdectection doesn't cause problems because we only use CONFIG_POSIX_MEMALIGN in oslib-posix.c; however that will change in a following commit. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20220226180723.1706285-6-peter.maydell@linaro.org Reviewed-by: Philippe Mathieu-Daudé --- meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 038502714ab..b541506c1c5 100644 --- a/meson.build +++ b/meson.build @@ -1619,7 +1619,9 @@ config_host_data.set('CONFIG_CLOCK_ADJTIME', cc.has_function('clock_adjtime')) config_host_data.set('CONFIG_DUP3', cc.has_function('dup3')) config_host_data.set('CONFIG_FALLOCATE', cc.has_function('fallocate')) config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate')) -config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign')) +# Note that we need to specify prefix: here to avoid incorrectly +# thinking that Windows has posix_memalign() +config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign', prefix: '#include ')) config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll')) config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include ')) config_host_data.set('CONFIG_SEM_TIMEDWAIT', cc.has_function('sem_timedwait', dependencies: threads)) From patchwork Mon Mar 7 16:46:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548869 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1091371wrl; Mon, 7 Mar 2022 08:48:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVGgMd2BjnQyxPvV8YAn3cgiBBjLcOXXn3QvSMysjWUKHtzCP7ioZct1U7GdBZh/ccrzcW X-Received: by 2002:a0d:fb45:0:b0:2d0:d09a:576c with SMTP id l66-20020a0dfb45000000b002d0d09a576cmr9449838ywf.447.1646671710200; Mon, 07 Mar 2022 08:48:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646671710; cv=none; d=google.com; s=arc-20160816; b=1EG0owD2APO6XWmXJkIKwfmuFYmTYRgR//pA84XTwssi1Uq2nrAfGgqg3U3He4SAqI 7vE/etdRLnCFWKfVIwr3Xv93vB3eWLqLxNEE58dd/0l6ufH3E1OSivNLX98PL9W8eEua qYGhl9JiEvEo13LP7285X+kNywDuCR9McuLSOoaIR9JqfrWApY9Be/DC7TVld/RnOM3z uUJaGdW/3bkzCs6Dl3LWCuZYNgs7DUlfo0+/QyO6N09g4YKuw/zGQ1mRjXiYlp91gIck F5yXuSrvMiC6Xbc7lyNq8OyIuXp3srxvtMqdCmHAJg5ypVh6PAR6XmG8QtQC+9NPrT9Z klpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=88/vli9sz3m24lTiI0cGWu1ovNoRhU1oqr+a87iSyJw=; b=sI6VC1sdWSJp2BTw0CByp2BKJjNgffEO0PneoP9CoLn0yDMxq8/darDnH47SUS6xaC pvYig8XNoFlOPDHDk+4V4bYYjeQjfSOjsHS1SSrhv+8KBZjxdQw1rlQCpTVe1TJXxRkb 3FLG41q72JBGLBTKZKVjHdBlu9yGAc2QO/kMU2oHeCo40RS2Gu3Pj/JGaFhYJ11wI5kd W6N+lTVdEosyeXNbG0xIeG/8bHfyzhsoDy6Clj0AbfqBTpcRWXaEh6DPH7AUsqDYAT8m iJq0Grb8nMOkDQlozxpTdLxIUUlgyHU3FApJCy4imdssPulS4fNf671FNaEzYEntEorI x05A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iDa9H092; 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 141-20020a250293000000b0062865f7a121si9020169ybc.34.2022.03.07.08.48.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:48:30 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iDa9H092; 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]:60864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGX7-0001Zy-Js for patch@linaro.org; Mon, 07 Mar 2022 11:48:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGVz-0001T5-80 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:19 -0500 Received: from [2a00:1450:4864:20::335] (port=56171 helo=mail-wm1-x335.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGVx-0007jP-GK for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:18 -0500 Received: by mail-wm1-x335.google.com with SMTP id i66so9554896wma.5 for ; Mon, 07 Mar 2022 08:47:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=88/vli9sz3m24lTiI0cGWu1ovNoRhU1oqr+a87iSyJw=; b=iDa9H092MybqwrOSEyObQw2tgUbZDEZNrbeQ6QZO49MO6OOpuzHuPBHqiWRmVLocmK 9Xd5C4c3iCOC2KUFqf8FLj/IQYhT1/I3YwQ0PFlFiLixY9UdKFWzVOZv1HwK9LLLWErE We8u2K9aP14MCgRlud1MbCum2iapB6JbJ2rQIBM16w7knAdwwgrDZYdx9osetAnIibZV 8FBJj80R3aTGXGOfz++GQpRkgqh7jz301QesimhTqIkoZtIOANphksc51NzXcOem1ODE 7D3q3U7v12dEAjUmrIKmB2A0gah4uSFBWwchMtVh2wuCWyjxWgqBUC3C35oomyJZE8k6 cqrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=88/vli9sz3m24lTiI0cGWu1ovNoRhU1oqr+a87iSyJw=; b=OdqW8xCnlgqX78tIZ+UDb1Qzsaxkk+fhaHsxq2GC4ChfcGVghpXzNPAvgLbkBCQ5c5 flNgAc6FtxMpkbBAnJo0F257n3Z34eLW/4Tu1qyZB/Ge9bIoWQfDkG591btk9Rn1/q8e 3OeeIMmcUYHRS2tOOI93GwYkPC92fsNGao2G4xaCkmoyXZ5zeynwZxgZBS/etxM0yvmU ZRtegUt5pnR6ADuZmDd8tce2QFp7zf8DAmvIUjAwwjJlc3k5ieuQXQuTP0JdaxqEqIHz pnuob3R3MLIQSni8og0180MWxEM+lylmeHnukNI2PyCX+G6IGZCj/Z6f7MrmOOwm1Jk4 Mf/w== X-Gm-Message-State: AOAM530pkx5YWKudAoAS4iMVWKOip+VeP8GfzWYELUXb8PDDiyyRYy+X Y3Qw/s3qa0pNvQbYWHcc0ByGGD6oyamZVw== X-Received: by 2002:a05:600c:154c:b0:382:6377:14bd with SMTP id f12-20020a05600c154c00b00382637714bdmr9949277wmg.125.1646671636166; Mon, 07 Mar 2022 08:47:16 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:15 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 05/18] util: Share qemu_try_memalign() implementation between POSIX and Windows Date: Mon, 7 Mar 2022 16:46:56 +0000 Message-Id: <20220307164709.2503250-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::335 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The qemu_try_memalign() functions for POSIX and Windows used to be significantly different, but these days they are identical except for the actual allocation function called, and the POSIX version already has to have ifdeffery for different allocation functions. Move to a single implementation in memalign.c, which uses the Windows _aligned_malloc if we detect that function in meson. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20220226180723.1706285-7-peter.maydell@linaro.org Reviewed-by: Philippe Mathieu-Daudé --- meson.build | 1 + util/memalign.c | 39 +++++++++++++++++++++++++++++++++++++++ util/oslib-posix.c | 29 ----------------------------- util/oslib-win32.c | 17 ----------------- 4 files changed, 40 insertions(+), 46 deletions(-) diff --git a/meson.build b/meson.build index b541506c1c5..bc0ac931e1a 100644 --- a/meson.build +++ b/meson.build @@ -1622,6 +1622,7 @@ config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate' # Note that we need to specify prefix: here to avoid incorrectly # thinking that Windows has posix_memalign() config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign', prefix: '#include ')) +config_host_data.set('CONFIG_ALIGNED_MALLOC', cc.has_function('_aligned_malloc')) config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll')) config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include ')) config_host_data.set('CONFIG_SEM_TIMEDWAIT', cc.has_function('sem_timedwait', dependencies: threads)) diff --git a/util/memalign.c b/util/memalign.c index 6dfc20abbb1..22b405700e3 100644 --- a/util/memalign.c +++ b/util/memalign.c @@ -25,6 +25,45 @@ */ #include "qemu/osdep.h" +#include "qemu/host-utils.h" +#include "trace.h" + +void *qemu_try_memalign(size_t alignment, size_t size) +{ + void *ptr; + + if (alignment < sizeof(void*)) { + alignment = sizeof(void*); + } else { + g_assert(is_power_of_2(alignment)); + } + + /* + * Handling of 0 allocations varies among the different + * platform APIs (for instance _aligned_malloc() will + * fail) -- ensure that we always return a valid non-NULL + * pointer that can be freed by qemu_vfree(). + */ + if (size == 0) { + size++; + } +#if defined(CONFIG_POSIX_MEMALIGN) + int ret; + ret = posix_memalign(&ptr, alignment, size); + if (ret != 0) { + errno = ret; + ptr = NULL; + } +#elif defined(CONFIG_ALIGNED_MALLOC) + ptr = _aligned_malloc(size, alignment); +#elif defined(CONFIG_BSD) + ptr = valloc(size); +#else + ptr = memalign(alignment, size); +#endif + trace_qemu_memalign(alignment, size, ptr); + return ptr; +} void *qemu_memalign(size_t alignment, size_t size) { diff --git a/util/oslib-posix.c b/util/oslib-posix.c index f7e22f4ff9b..91798f7e504 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -199,35 +199,6 @@ fail_close: return false; } -void *qemu_try_memalign(size_t alignment, size_t size) -{ - void *ptr; - - if (alignment < sizeof(void*)) { - alignment = sizeof(void*); - } else { - g_assert(is_power_of_2(alignment)); - } - - if (size == 0) { - size++; - } -#if defined(CONFIG_POSIX_MEMALIGN) - int ret; - ret = posix_memalign(&ptr, alignment, size); - if (ret != 0) { - errno = ret; - ptr = NULL; - } -#elif defined(CONFIG_BSD) - ptr = valloc(size); -#else - ptr = memalign(alignment, size); -#endif - trace_qemu_memalign(alignment, size, ptr); - return ptr; -} - /* alloc shared memory pages */ void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment, bool shared, bool noreserve) diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 8c28d70904d..d9768532bec 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -44,23 +44,6 @@ /* this must come after including "trace.h" */ #include -void *qemu_try_memalign(size_t alignment, size_t size) -{ - void *ptr; - - if (alignment < sizeof(void *)) { - alignment = sizeof(void *); - } else { - g_assert(is_power_of_2(alignment)); - } - if (size == 0) { - size++; - } - ptr = _aligned_malloc(size, alignment); - trace_qemu_memalign(alignment, size, ptr); - return ptr; -} - static int get_allocation_granularity(void) { SYSTEM_INFO system_info; From patchwork Mon Mar 7 16:46:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548878 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1094936wrl; Mon, 7 Mar 2022 08:54:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJz993xgO2T+PwtgHYM7fqSKpJSGiKd6o24CUWJhNYze466Pa9gwq1peqb8FDndNoLkBdMVY X-Received: by 2002:a81:397:0:b0:2db:645b:c8e5 with SMTP id 145-20020a810397000000b002db645bc8e5mr9444917ywd.421.1646672061179; Mon, 07 Mar 2022 08:54:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646672061; cv=none; d=google.com; s=arc-20160816; b=JaxvbYBV2e4wH6fdSa4UIfwwRZq7Em/IS+U0YYaTpQ4wJTboOgOcQrgygUqvklFuWd 87ILJ5RRMcp0UTvTIz+z/IpJCeKEvdJRTACEpwB4P/UxAhSEEzjXeDsUwBw44Wb3Ax43 toXgPd3fb0rCNSRbyaMQCtu0GWBJm6JIlyuycGGYRfDQ4vEO7i5wHOvx2clYcEG22GeC siqTj40LVXsyD0Wc2QRjMCNRxqwaCCnxdnYjRvULZm/XTOAco7E9fDxpGtMg119kCJWa /5jI/ZJA4w24KDhwvKrgfseK2pQ63+ZAl6wyqjWOqDWwAEhKPIl7vhvBT1RClj1KdAm4 Nrng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=NaCmncalisG2HmxfoLWWRFVxRQONisu66EFRvxsSlWo=; b=R5VB7sTIs2USA1OfzalbZsolNrm7ceQ3Ihprc6np2PzpWpKKkPClxnq7oKdmn+z0TI M50B9dpyqOndC/Tt4EgDKTGe3D8a6jFEl+DN6XI6E0Pzcr+zv3lqmvbAop6KpoL8VeZ1 sL6z8auqcnHkqGUf2wPNDU3OXWNbE1EJMCKi/WyV4ZD6cAcBFAZ83XEVHwOeJL+XB+Jb WncDOxC+MCTZODsSWZSqqvtLv3szoZuytQap+gKPvc2fB8TvMeEkkBqrzmsYUQ/wXWFU tx5rMYsp8QsgLOUrlTF/873fWvJe22wqgseVp0IFSq8z4CkeKhijwWAsum75Im2xiGTs V+nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="F/wj2lrR"; 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 bc2-20020a05690c000200b002dcaca9dcf8si3424608ywb.414.2022.03.07.08.54.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:54:21 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="F/wj2lrR"; 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]:55010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGcm-0007yI-Kd for patch@linaro.org; Mon, 07 Mar 2022 11:54:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGVz-0001Um-Qx for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:19 -0500 Received: from [2a00:1450:4864:20::335] (port=42741 helo=mail-wm1-x335.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGVy-0007je-74 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:19 -0500 Received: by mail-wm1-x335.google.com with SMTP id r187-20020a1c2bc4000000b003810e6b192aso9669636wmr.1 for ; Mon, 07 Mar 2022 08:47:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=NaCmncalisG2HmxfoLWWRFVxRQONisu66EFRvxsSlWo=; b=F/wj2lrRFSQ/W1yKkYWTYcQlJt81DPS3nXJ09Sa+3XiMHXwxa9ojTCkYKrc8Wxj9nP CCU6rmxOZzZ5q1oJS4mSyXkcVvSW5VlvOQawsmLOwZmhNWPiUARBXmvg6jtyKgNw3GW8 h9D0Ddz1mXT9NmIdVZ4m9VzqJ6+yXxe1dKckucpXfkVVDzCnRFscl/XjCzf6K1mqyCfT rIKktLmwgk2joL0KYU2fPjJL2uaFKf8b3Fu/6QTSqoDwxZEn5ze2nsV1uTEN/AQzRoxN 7vb2F7jcvoKrRo8Gpj4O3Y/Z2kBRo/zhujmtGe1emp5yuB5ibPVDU80yS31soL6hBIw0 CGVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NaCmncalisG2HmxfoLWWRFVxRQONisu66EFRvxsSlWo=; b=T8Cy60/LZ9fIFWAxxTCSO0/tUcovpCnpPzIY2A8FXYXOXCgqKlaPQ3kEAkGUNN9dXA ByxCN3mhQj2zeIuezFlZSsl9RWqve4nvWPnlxI7nUWVjBY3q2VM2i1Bqoss2f4i7Gzex g7GJYeM6mVkF5YpE2DBYhBSAxGyHNKyPDfjFZIU+slWUYyP6XcgqCq4okrtRFvgJa7/4 Tb8db8AmDUCLDcKGP6UHggHmg9sqlDup+Mxy67/dhbie96EVnSfElAzDeBRcPcTn3byZ AfWpKbkOwdAOaiFfFGBFzHXRh2r6bbyaWOig78i61enFmw0Se85EKLyy8kJncJEljwz0 c8Dg== X-Gm-Message-State: AOAM5317/2Lf/DTDpE5sO1edn+XDjca+4LmkX4wCX7RW41NyCin4fdVe N4uNcIZdQKGQuAvMRkMcqcYkINktNUP7dw== X-Received: by 2002:a05:600c:4f0c:b0:389:990e:d9f4 with SMTP id l12-20020a05600c4f0c00b00389990ed9f4mr8490955wmq.90.1646671636900; Mon, 07 Mar 2022 08:47:16 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:16 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 06/18] util: Use meson checks for valloc() and memalign() presence Date: Mon, 7 Mar 2022 16:46:57 +0000 Message-Id: <20220307164709.2503250-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::335 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Instead of assuming that all CONFIG_BSD have valloc() and anything else is memalign(), explicitly check for those functions in meson.build and use the "is the function present" define. Tests for specific functionality are better than which-OS checks; this also lets us give a helpful error message if somehow there's no usable function present. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-id: 20220226180723.1706285-8-peter.maydell@linaro.org --- meson.build | 2 ++ util/memalign.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index bc0ac931e1a..774d0248a62 100644 --- a/meson.build +++ b/meson.build @@ -1623,6 +1623,8 @@ config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate' # thinking that Windows has posix_memalign() config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign', prefix: '#include ')) config_host_data.set('CONFIG_ALIGNED_MALLOC', cc.has_function('_aligned_malloc')) +config_host_data.set('CONFIG_VALLOC', cc.has_function('valloc')) +config_host_data.set('CONFIG_MEMALIGN', cc.has_function('memalign')) config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll')) config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include ')) config_host_data.set('CONFIG_SEM_TIMEDWAIT', cc.has_function('sem_timedwait', dependencies: threads)) diff --git a/util/memalign.c b/util/memalign.c index 22b405700e3..083aaae619c 100644 --- a/util/memalign.c +++ b/util/memalign.c @@ -56,10 +56,12 @@ void *qemu_try_memalign(size_t alignment, size_t size) } #elif defined(CONFIG_ALIGNED_MALLOC) ptr = _aligned_malloc(size, alignment); -#elif defined(CONFIG_BSD) +#elif defined(CONFIG_VALLOC) ptr = valloc(size); -#else +#elif defined(CONFIG_MEMALIGN) ptr = memalign(alignment, size); +#else + #error No function to allocate aligned memory available #endif trace_qemu_memalign(alignment, size, ptr); return ptr; From patchwork Mon Mar 7 16:46:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548881 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1095857wrl; Mon, 7 Mar 2022 08:55:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRL40+NrIJxjyhGFc/0xJZZjBJZvy+8AEbovDKMCwhU7RvF/s+czEyliCzmEaWrzkgK+cl X-Received: by 2002:a25:9984:0:b0:624:5b01:5075 with SMTP id p4-20020a259984000000b006245b015075mr8376745ybo.463.1646672140648; Mon, 07 Mar 2022 08:55:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646672140; cv=none; d=google.com; s=arc-20160816; b=yc7ClJE53mFroIQohOxFHOluKvRnVtZvrgu26R9aug5IG+VNYifBIY4CbTp7l2wQf5 ggqPwQfGhBiNwCDoOhbzU7Ytxi9jFCwc7YNwI03q4RuhpmQ2S4QOIj/+S+GUZRPGdEhS q7rh/xKtbJOAKQDzCkklRnc4bpuOL1BsaEB1V4sviQ8RROBVp4P2BEMwMjGjbkKp50Hx pdnLzsYh0UTv42yPH77d7AUzhGyTcabr9J6957eECjODd2z467zbtZRUm4nrpmZdwTmJ UxuTSgbe0lN6U5iTPrKvtOlYqX7nn1qxTbfyWt/IUPXGNZcQAqSMvyycEM4YrsEBxwC3 S6lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=FESTC/0BZsNEujezQb148jTd0VqMzayMHKHa6G291j4=; b=VsfVtsMA5zxpPmJDJczEpBdhw5SJoM5eh1xsu9YN75Jjh6+v266jImowBczsrc/deA qAHNPqWlEAXVb76ScnvKNgK0bHt0dYsPKp6pDuHVi3xeq44OvQcfys2vIGCJ5gCxTy1v G8x89WdJgwI+yr9A2FJIymuPmaUL2iPe7zeseOgPXfN1wWnSiDhg4c6ry16AjachLibS 8OsBo93lULIqr91TRa+pc/a5QbdA1ZSfNr5urN1sp2sJJ6SSzETXEavbMCrWWXj0EL4E gX7Jr+51KU5MWYkoviAIFR7+DhkbKHD14sCs/z8oS08JWHGrbBa38QD6VryIhAqpNhho O1tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bcyXpi2u; 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 bc2-20020a05690c000200b002dcaca9dcf8si3427052ywb.414.2022.03.07.08.55.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:55:40 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bcyXpi2u; 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]:33248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGe4-0003n8-2q for patch@linaro.org; Mon, 07 Mar 2022 11:55:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGW0-0001Wp-H9 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:20 -0500 Received: from [2a00:1450:4864:20::32c] (port=33993 helo=mail-wm1-x32c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGVy-0007jw-VU for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:20 -0500 Received: by mail-wm1-x32c.google.com with SMTP id k8-20020a05600c1c8800b003899c7ac55dso197080wms.1 for ; Mon, 07 Mar 2022 08:47:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=FESTC/0BZsNEujezQb148jTd0VqMzayMHKHa6G291j4=; b=bcyXpi2u7b757mR/7vciHB5XPXLe+n8WxN07JDjKkVVzm16Zh1Q5RevZwwHbVPwFV7 w40o2w3MlOR8nfWt6+auDqXgih/+xvSlnzBMq2dA+f3zXK8cyinvavjm2sd7uxrwcTFE GoJ2QesyiSUKFL4JdRrTAmo49tjkgE1V5nDTtz8T/5g1j4cJolPhuz6Ta0N5nqKWj+iR afgX7Lh8gKqHALiVnXpr+3joa2Vgo+bRHv+amRvter1b53VNUFMmoWljqER2xcRcA9Vw eXATzt8VTce82c+w/30IrVP1rrKDaub6dvBSZhcHZL/5PrfUu0wrTkofE/D9+0F38sTE wzAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FESTC/0BZsNEujezQb148jTd0VqMzayMHKHa6G291j4=; b=hQ1NYv0Jqku/+adTzHGvBffLF297lu4YFDMizewEolSHwX6RNLRsNIQPN3v7v5Zmpu HsvLUsJotzZ3kGbAl9RSOVwybgK2EJ8N6Og8zi68IeIKhFr9IzAw/zwxPMC916W586pM DwOU0q3jOPLHg/+z7COoKsc0CNbGLKB/aMtw6Ylo6rQMWkRRCz/MMwUB2FwlqXbT69AX UMad+AknWGzEfRUyJ2vulONr4fif8NTdOTpiGQnjblhr59IqSwXDBcwWBw3jZ3liUD8H wHvBCDlHvSzhY9IR/w/nrklyUiPkw1qV6+umYptaMdechsyp+eXVBvWrrYfkAbjlqLi9 pBJQ== X-Gm-Message-State: AOAM5301k0Nk0HBrcgAAgC0k/SEGLO2Vx1u4RcGn8/RORaKPknHsT7jg ScJfUR+Mw7ZibukBzt0yp27l5eqaNT5vwA== X-Received: by 2002:a05:600c:2846:b0:389:9347:9aaf with SMTP id r6-20020a05600c284600b0038993479aafmr9635461wmb.87.1646671637689; Mon, 07 Mar 2022 08:47:17 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:17 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 07/18] util: Put qemu_vfree() in memalign.c Date: Mon, 7 Mar 2022 16:46:58 +0000 Message-Id: <20220307164709.2503250-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32c (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" qemu_vfree() is the companion free function to qemu_memalign(); put it in memalign.c so the allocation and free functions are together. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20220226180723.1706285-9-peter.maydell@linaro.org Reviewed-by: Philippe Mathieu-Daudé --- util/memalign.c | 11 +++++++++++ util/oslib-posix.c | 6 ------ util/oslib-win32.c | 6 ------ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/util/memalign.c b/util/memalign.c index 083aaae619c..440b8fd9a76 100644 --- a/util/memalign.c +++ b/util/memalign.c @@ -78,3 +78,14 @@ void *qemu_memalign(size_t alignment, size_t size) size, alignment, strerror(errno)); abort(); } + +void qemu_vfree(void *ptr) +{ + trace_qemu_vfree(ptr); +#if !defined(CONFIG_POSIX_MEMALIGN) && defined(CONFIG_ALIGNED_MALLOC) + /* Only Windows _aligned_malloc needs a special free function */ + _aligned_free(ptr); +#else + free(ptr); +#endif +} diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 91798f7e504..2ebfb750578 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -220,12 +220,6 @@ void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment, bool shared, return ptr; } -void qemu_vfree(void *ptr) -{ - trace_qemu_vfree(ptr); - free(ptr); -} - void qemu_anon_ram_free(void *ptr, size_t size) { trace_qemu_anon_ram_free(ptr, size); diff --git a/util/oslib-win32.c b/util/oslib-win32.c index d9768532bec..4b1ce0be4b0 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -75,12 +75,6 @@ void *qemu_anon_ram_alloc(size_t size, uint64_t *align, bool shared, return ptr; } -void qemu_vfree(void *ptr) -{ - trace_qemu_vfree(ptr); - _aligned_free(ptr); -} - void qemu_anon_ram_free(void *ptr, size_t size) { trace_qemu_anon_ram_free(ptr, size); From patchwork Mon Mar 7 16:46:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548870 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1091425wrl; Mon, 7 Mar 2022 08:48:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxIcKYAeHkQImXtgrLyg4l7hJbr5lPRi7KQ3mO1n+QUrX7dljyS5A/xGfgnhCH/zdo6F688 X-Received: by 2002:a25:778b:0:b0:628:919f:7088 with SMTP id s133-20020a25778b000000b00628919f7088mr8817926ybc.282.1646671716018; Mon, 07 Mar 2022 08:48:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646671716; cv=none; d=google.com; s=arc-20160816; b=XfpyX8ULmfXg9qQ/MeYkJGtg2LV2QjhYmGcgJsNaYRnmxEAakqAfte68T2BKTR2tSJ Zejo0KKlD5UtAzaX7kmRB1ByqXH6pCJwCowJgHWIEV0Ot0LXbqWTwgNiUfL4oMsfDp2S wXDDHyoLrWPanLDueKWVP1sD5bHJLD2qkpowcHKodFyZzQKbwTZJLDH6OSaL5F5mTu4W NoRiFq9FyKCysi44FXXlVuwf6WdISHHu4is+cbOo0BmP9X/2naOQE5U6ILrFXUtdG8wO qXUNmRNh+mM0NW4AnfHMWsWTQeMyBI8mBJq4LsIhSQ9y0lNm1ZL0nd/D/8POXmDIchOX n+4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=NXJeKfiydTxWODRLKaEdrTagQPu6Toife0/QFAZ3RT4=; b=zGNj+0SycoQCrPwiiazDgRkgwvXJODenj6FLmh8odMup4JNdM7D7o4x/j08doVkAPG /sP82c/5LkBK8sxUed0u+DrJheUZ0ViHgQvYPPjaUyXd63HPRuexrQlvO03b31I98RoQ 4l526r4GJYsJPWoCywZYgtnL3Jhh7Wetk1K5zE0O8LyII564JrHUifdI66YowE1cvIyN Lzj91vwFZDHn8GwNABDOKxTCBL/oKjHiyotwREArt3FXjhhrapa/DM0bGN5rCROWTmKo 0mK0Vrnqw8BHbzEmTJfOLIXCCPyzTYbDuSL2+eNhrdjVA5f23PIPGiN1MMeChjS1SKhC M+mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rs5MFR6s; 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 k128-20020a819386000000b002dc09fe8a0asi10708959ywg.450.2022.03.07.08.48.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:48:36 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rs5MFR6s; 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]:32928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGXD-0001mI-CU for patch@linaro.org; Mon, 07 Mar 2022 11:48:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGW3-0001fm-9p for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:23 -0500 Received: from [2a00:1450:4864:20::32e] (port=36380 helo=mail-wm1-x32e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGW0-0007kP-GC for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:23 -0500 Received: by mail-wm1-x32e.google.com with SMTP id n31-20020a05600c3b9f00b003898fc06f1eso486244wms.1 for ; Mon, 07 Mar 2022 08:47:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=NXJeKfiydTxWODRLKaEdrTagQPu6Toife0/QFAZ3RT4=; b=Rs5MFR6sMT7EKbRlfxu/ozi59p30i2ldUsx2rtmAhrye9pYY1ul/pa729HHnOuDRK/ C9MZ/GslSZQSf62qHCrh6RIEfAcsXQpd15dyxHNi0oE9w7tws+xZMSFrOxiB+RQO+ZkW cP+LV2QI+dHK+8PsecH87agRsOKjRtRdN97NZuueI6n5k9uqCogp5xxtENyb8rBzyczq d1uY/JZKxRWhfJrNbwWC/18eaW5o6jtpzCtvzn+9T5K5Sixt4HYQHodFFoFT4IQsUnnA 5TjXf5AmmpovvNzfwXGHy/dDQvumZmE8Z3wDGEWdQ7fn5wDSBEGuN/V7+OTBkuLcnDhH ip6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NXJeKfiydTxWODRLKaEdrTagQPu6Toife0/QFAZ3RT4=; b=dmcJHTt76OG0k+j3LQeSHFH9ay4PypOJThRgHTtBzwxLx1WAySP/TaAH6QRI6Y7ZXB 9RrlwWXWJLcSZoAapqq1te0RNN1mc2c93q2LFP26mnLuzJPCoAyEVg7b5Zkgogdzug9V cWr6SzHP+6wvISbTyb94SlQTx2HKd2xGq4ZVTI9W95zDNV4xhrko4kLv4TD1O7frElpZ M8wUAbcssXw8QuZpiOC8ZF9G+xVdwFvxcC48umfdHatz7i2ZvSLWbvXI5jLH8Rjysnqd d8eO3D1MOBjC9XmuBZyRksJ1gsUgmZTNXQs3QXfSUn4QoIfK5FdmJkdVN0+ilsUvae6M f1ig== X-Gm-Message-State: AOAM530C5OP0fk7Du30kKxzduSZe3+lIOzcCLRqMbNwxHlhuQkAQlc2Y QtwGvDrGBQrBY2tJay8RlBMQ82WF3ICwXA== X-Received: by 2002:a7b:cb8d:0:b0:389:7389:ff9b with SMTP id m13-20020a7bcb8d000000b003897389ff9bmr9994118wmi.32.1646671638899; Mon, 07 Mar 2022 08:47:18 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:18 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 08/18] osdep: Move memalign-related functions to their own header Date: Mon, 7 Mar 2022 16:46:59 +0000 Message-Id: <20220307164709.2503250-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32e (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Move the various memalign-related functions out of osdep.h and into their own header, which we include only where they are used. While we're doing this, add some brief documentation comments. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-id: 20220226180723.1706285-10-peter.maydell@linaro.org --- include/qemu/memalign.h | 61 ++++++++++++++++++++++++++++++++++ include/qemu/osdep.h | 18 ---------- block/blkverify.c | 1 + block/block-copy.c | 1 + block/commit.c | 1 + block/crypto.c | 1 + block/dmg.c | 1 + block/export/fuse.c | 1 + block/file-posix.c | 1 + block/io.c | 1 + block/mirror.c | 1 + block/nvme.c | 1 + block/parallels-ext.c | 1 + block/parallels.c | 1 + block/qcow.c | 1 + block/qcow2-cache.c | 1 + block/qcow2-cluster.c | 1 + block/qcow2-refcount.c | 1 + block/qcow2-snapshot.c | 1 + block/qcow2.c | 1 + block/qed-l2-cache.c | 1 + block/qed-table.c | 1 + block/qed.c | 1 + block/quorum.c | 1 + block/raw-format.c | 1 + block/vdi.c | 1 + block/vhdx-log.c | 1 + block/vhdx.c | 1 + block/vmdk.c | 1 + block/vpc.c | 1 + block/win32-aio.c | 1 + hw/block/dataplane/xen-block.c | 1 + hw/block/fdc.c | 1 + hw/ide/core.c | 1 + hw/ppc/spapr.c | 1 + hw/ppc/spapr_softmmu.c | 1 + hw/scsi/scsi-disk.c | 1 + hw/tpm/tpm_ppi.c | 2 +- nbd/server.c | 1 + net/l2tpv3.c | 2 +- plugins/loader.c | 1 + qemu-img.c | 1 + qemu-io-cmds.c | 1 + qom/object.c | 1 + softmmu/physmem.c | 1 + target/i386/hvf/hvf.c | 1 + target/i386/kvm/kvm.c | 1 + tcg/region.c | 1 + tests/bench/atomic_add-bench.c | 1 + tests/bench/qht-bench.c | 1 + util/atomic64.c | 1 + util/memalign.c | 1 + util/qht.c | 1 + 53 files changed, 112 insertions(+), 20 deletions(-) create mode 100644 include/qemu/memalign.h diff --git a/include/qemu/memalign.h b/include/qemu/memalign.h new file mode 100644 index 00000000000..fa299f3bf67 --- /dev/null +++ b/include/qemu/memalign.h @@ -0,0 +1,61 @@ +/* + * Allocation and free functions for aligned memory + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_MEMALIGN_H +#define QEMU_MEMALIGN_H + +/** + * qemu_try_memalign: Allocate aligned memory + * @alignment: required alignment, in bytes + * @size: size of allocation, in bytes + * + * Allocate memory on an aligned boundary (i.e. the returned + * address will be an exact multiple of @alignment). + * @alignment must be a power of 2, or the function will assert(). + * On success, returns allocated memory; on failure, returns NULL. + * + * The memory allocated through this function must be freed via + * qemu_vfree() (and not via free()). + */ +void *qemu_try_memalign(size_t alignment, size_t size); +/** + * qemu_memalign: Allocate aligned memory, without failing + * @alignment: required alignment, in bytes + * @size: size of allocation, in bytes + * + * Allocate memory in the same way as qemu_try_memalign(), but + * abort() with an error message if the memory allocation fails. + * + * The memory allocated through this function must be freed via + * qemu_vfree() (and not via free()). + */ +void *qemu_memalign(size_t alignment, size_t size); +/** + * qemu_vfree: Free memory allocated through qemu_memalign + * @ptr: memory to free + * + * This function must be used to free memory allocated via qemu_memalign() + * or qemu_try_memalign(). (Using the wrong free function will cause + * subtle bugs on Windows hosts.) + */ +void qemu_vfree(void *ptr); +/* + * It's an analog of GLIB's g_autoptr_cleanup_generic_gfree(), used to define + * g_autofree macro. + */ +static inline void qemu_cleanup_generic_vfree(void *p) +{ + void **pp = (void **)p; + qemu_vfree(*pp); +} + +/* + * Analog of g_autofree, but qemu_vfree is called on cleanup instead of g_free. + */ +#define QEMU_AUTO_VFREE __attribute__((cleanup(qemu_cleanup_generic_vfree))) + +#endif diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 7bcce3bceb0..bc3df26da36 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -379,28 +379,10 @@ extern "C" { #endif int qemu_daemon(int nochdir, int noclose); -void *qemu_try_memalign(size_t alignment, size_t size); -void *qemu_memalign(size_t alignment, size_t size); void *qemu_anon_ram_alloc(size_t size, uint64_t *align, bool shared, bool noreserve); -void qemu_vfree(void *ptr); void qemu_anon_ram_free(void *ptr, size_t size); -/* - * It's an analog of GLIB's g_autoptr_cleanup_generic_gfree(), used to define - * g_autofree macro. - */ -static inline void qemu_cleanup_generic_vfree(void *p) -{ - void **pp = (void **)p; - qemu_vfree(*pp); -} - -/* - * Analog of g_autofree, but qemu_vfree is called on cleanup instead of g_free. - */ -#define QEMU_AUTO_VFREE __attribute__((cleanup(qemu_cleanup_generic_vfree))) - #ifdef _WIN32 #define HAVE_CHARDEV_SERIAL 1 #elif defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ diff --git a/block/blkverify.c b/block/blkverify.c index d1facf5ba90..53ba1c91957 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -16,6 +16,7 @@ #include "qemu/cutils.h" #include "qemu/module.h" #include "qemu/option.h" +#include "qemu/memalign.h" typedef struct { BdrvChild *test_file; diff --git a/block/block-copy.c b/block/block-copy.c index ce116318b57..619e5580faf 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -22,6 +22,7 @@ #include "qemu/coroutine.h" #include "block/aio_task.h" #include "qemu/error-report.h" +#include "qemu/memalign.h" #define BLOCK_COPY_MAX_COPY_RANGE (16 * MiB) #define BLOCK_COPY_MAX_BUFFER (1 * MiB) diff --git a/block/commit.c b/block/commit.c index c76899f640c..851d1c557a1 100644 --- a/block/commit.c +++ b/block/commit.c @@ -20,6 +20,7 @@ #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "qemu/ratelimit.h" +#include "qemu/memalign.h" #include "sysemu/block-backend.h" enum { diff --git a/block/crypto.c b/block/crypto.c index 9d5fecbef86..1ba82984efe 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -31,6 +31,7 @@ #include "qemu/module.h" #include "qemu/option.h" #include "qemu/cutils.h" +#include "qemu/memalign.h" #include "crypto.h" typedef struct BlockCrypto BlockCrypto; diff --git a/block/dmg.c b/block/dmg.c index 447901fbb87..c626587f9c5 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -27,6 +27,7 @@ #include "qemu/bswap.h" #include "qemu/error-report.h" #include "qemu/module.h" +#include "qemu/memalign.h" #include "dmg.h" int (*dmg_uncompress_bz2)(char *next_in, unsigned int avail_in, diff --git a/block/export/fuse.c b/block/export/fuse.c index 5029e70f843..e80b24a8671 100644 --- a/block/export/fuse.c +++ b/block/export/fuse.c @@ -19,6 +19,7 @@ #define FUSE_USE_VERSION 31 #include "qemu/osdep.h" +#include "qemu/memalign.h" #include "block/aio.h" #include "block/block.h" #include "block/export.h" diff --git a/block/file-posix.c b/block/file-posix.c index 1f1756e192a..c000a61db29 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -31,6 +31,7 @@ #include "qemu/module.h" #include "qemu/option.h" #include "qemu/units.h" +#include "qemu/memalign.h" #include "trace.h" #include "block/thread-pool.h" #include "qemu/iov.h" diff --git a/block/io.c b/block/io.c index efc011ce657..8e621a49464 100644 --- a/block/io.c +++ b/block/io.c @@ -32,6 +32,7 @@ #include "block/coroutines.h" #include "block/write-threshold.h" #include "qemu/cutils.h" +#include "qemu/memalign.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" diff --git a/block/mirror.c b/block/mirror.c index ce6bc58d1f4..d8ecb9efa29 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -23,6 +23,7 @@ #include "qapi/qmp/qerror.h" #include "qemu/ratelimit.h" #include "qemu/bitmap.h" +#include "qemu/memalign.h" #define MAX_IN_FLIGHT 16 #define MAX_IO_BYTES (1 << 20) /* 1 Mb */ diff --git a/block/nvme.c b/block/nvme.c index dd20de3865b..552029931d5 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -21,6 +21,7 @@ #include "qemu/module.h" #include "qemu/cutils.h" #include "qemu/option.h" +#include "qemu/memalign.h" #include "qemu/vfio-helpers.h" #include "block/block_int.h" #include "sysemu/replay.h" diff --git a/block/parallels-ext.c b/block/parallels-ext.c index e0dd0975c6f..cb22a427d72 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -29,6 +29,7 @@ #include "parallels.h" #include "crypto/hash.h" #include "qemu/uuid.h" +#include "qemu/memalign.h" #define PARALLELS_FORMAT_EXTENSION_MAGIC 0xAB234CEF23DCEA87ULL diff --git a/block/parallels.c b/block/parallels.c index e58c8284222..cd23e02d06c 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -41,6 +41,7 @@ #include "qapi/qapi-visit-block-core.h" #include "qemu/bswap.h" #include "qemu/bitmap.h" +#include "qemu/memalign.h" #include "migration/blocker.h" #include "parallels.h" diff --git a/block/qcow.c b/block/qcow.c index c39940f33eb..4fba1b9e364 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -32,6 +32,7 @@ #include "qemu/option.h" #include "qemu/bswap.h" #include "qemu/cutils.h" +#include "qemu/memalign.h" #include #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 7444b9c4ab0..8a0105911f7 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -23,6 +23,7 @@ */ #include "qemu/osdep.h" +#include "qemu/memalign.h" #include "qcow2.h" #include "trace.h" diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 21884a1ab9a..20a16ba6ee0 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -28,6 +28,7 @@ #include "qapi/error.h" #include "qcow2.h" #include "qemu/bswap.h" +#include "qemu/memalign.h" #include "trace.h" int qcow2_shrink_l1_table(BlockDriverState *bs, uint64_t exact_size) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 46145722527..94033972bed 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -28,6 +28,7 @@ #include "qemu/range.h" #include "qemu/bswap.h" #include "qemu/cutils.h" +#include "qemu/memalign.h" #include "trace.h" static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t size, diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 71ddb08c212..075269a0237 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -29,6 +29,7 @@ #include "qemu/bswap.h" #include "qemu/error-report.h" #include "qemu/cutils.h" +#include "qemu/memalign.h" static void qcow2_free_single_snapshot(BlockDriverState *bs, int i) { diff --git a/block/qcow2.c b/block/qcow2.c index c8115e1cba0..b5c47931ef4 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -38,6 +38,7 @@ #include "qemu/option_int.h" #include "qemu/cutils.h" #include "qemu/bswap.h" +#include "qemu/memalign.h" #include "qapi/qobject-input-visitor.h" #include "qapi/qapi-visit-block-core.h" #include "crypto.h" diff --git a/block/qed-l2-cache.c b/block/qed-l2-cache.c index b5483623989..caf2c024c2d 100644 --- a/block/qed-l2-cache.c +++ b/block/qed-l2-cache.c @@ -51,6 +51,7 @@ */ #include "qemu/osdep.h" +#include "qemu/memalign.h" #include "trace.h" #include "qed.h" diff --git a/block/qed-table.c b/block/qed-table.c index 405d446cbe7..1cc844b1a5f 100644 --- a/block/qed-table.c +++ b/block/qed-table.c @@ -17,6 +17,7 @@ #include "qemu/sockets.h" /* for EINPROGRESS on Windows */ #include "qed.h" #include "qemu/bswap.h" +#include "qemu/memalign.h" /* Called with table_lock held. */ static int coroutine_fn qed_read_table(BDRVQEDState *s, uint64_t offset, diff --git a/block/qed.c b/block/qed.c index 558d3646c4b..f34d9a3ac1a 100644 --- a/block/qed.c +++ b/block/qed.c @@ -20,6 +20,7 @@ #include "qemu/main-loop.h" #include "qemu/module.h" #include "qemu/option.h" +#include "qemu/memalign.h" #include "trace.h" #include "qed.h" #include "sysemu/block-backend.h" diff --git a/block/quorum.c b/block/quorum.c index c28dda7baac..f33f30d36b8 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -17,6 +17,7 @@ #include "qemu/cutils.h" #include "qemu/module.h" #include "qemu/option.h" +#include "qemu/memalign.h" #include "block/block_int.h" #include "block/coroutines.h" #include "block/qdict.h" diff --git a/block/raw-format.c b/block/raw-format.c index bda757fd195..69fd650eaf7 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -31,6 +31,7 @@ #include "qapi/error.h" #include "qemu/module.h" #include "qemu/option.h" +#include "qemu/memalign.h" typedef struct BDRVRawState { uint64_t offset; diff --git a/block/vdi.c b/block/vdi.c index bdc58d726ee..cca3a3a3567 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -64,6 +64,7 @@ #include "qemu/coroutine.h" #include "qemu/cutils.h" #include "qemu/uuid.h" +#include "qemu/memalign.h" /* Code configuration options. */ diff --git a/block/vhdx-log.c b/block/vhdx-log.c index 7672161d955..ff0d4e0da05 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -23,6 +23,7 @@ #include "block/block_int.h" #include "qemu/error-report.h" #include "qemu/bswap.h" +#include "qemu/memalign.h" #include "vhdx.h" diff --git a/block/vhdx.c b/block/vhdx.c index 356ec4c455a..410c6f96101 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -25,6 +25,7 @@ #include "qemu/crc32c.h" #include "qemu/bswap.h" #include "qemu/error-report.h" +#include "qemu/memalign.h" #include "vhdx.h" #include "migration/blocker.h" #include "qemu/uuid.h" diff --git a/block/vmdk.c b/block/vmdk.c index 0dfab6e9413..37c0946066e 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -33,6 +33,7 @@ #include "qemu/module.h" #include "qemu/option.h" #include "qemu/bswap.h" +#include "qemu/memalign.h" #include "migration/blocker.h" #include "qemu/cutils.h" #include diff --git a/block/vpc.c b/block/vpc.c index 297a26262ab..4d8f16e1990 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -33,6 +33,7 @@ #include "migration/blocker.h" #include "qemu/bswap.h" #include "qemu/uuid.h" +#include "qemu/memalign.h" #include "qapi/qmp/qdict.h" #include "qapi/qobject-input-visitor.h" #include "qapi/qapi-visit-block-core.h" diff --git a/block/win32-aio.c b/block/win32-aio.c index c57e10c9979..aadc7b1bc3c 100644 --- a/block/win32-aio.c +++ b/block/win32-aio.c @@ -29,6 +29,7 @@ #include "block/raw-aio.h" #include "qemu/event_notifier.h" #include "qemu/iov.h" +#include "qemu/memalign.h" #include #include diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c index 860787580a3..2785b9e8497 100644 --- a/hw/block/dataplane/xen-block.c +++ b/hw/block/dataplane/xen-block.c @@ -21,6 +21,7 @@ #include "qemu/osdep.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" +#include "qemu/memalign.h" #include "qapi/error.h" #include "hw/xen/xen_common.h" #include "hw/block/xen_blkif.h" diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 21d18ac2e36..347875a0cda 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -32,6 +32,7 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/timer.h" +#include "qemu/memalign.h" #include "hw/irq.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h" diff --git a/hw/ide/core.c b/hw/ide/core.c index 33463d9b8f2..a7ac4de18ad 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -30,6 +30,7 @@ #include "qemu/main-loop.h" #include "qemu/timer.h" #include "qemu/hw-version.h" +#include "qemu/memalign.h" #include "sysemu/sysemu.h" #include "sysemu/blockdev.h" #include "sysemu/dma.h" diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 4cc204f90df..953fc65fa86 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -27,6 +27,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/datadir.h" +#include "qemu/memalign.h" #include "qapi/error.h" #include "qapi/qapi-events-machine.h" #include "qapi/qapi-events-qdev.h" diff --git a/hw/ppc/spapr_softmmu.c b/hw/ppc/spapr_softmmu.c index 4ee03c83e48..5170a33369e 100644 --- a/hw/ppc/spapr_softmmu.c +++ b/hw/ppc/spapr_softmmu.c @@ -1,5 +1,6 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" +#include "qemu/memalign.h" #include "cpu.h" #include "helper_regs.h" #include "hw/ppc/spapr.h" diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 3666b8d9468..072686ed58f 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -26,6 +26,7 @@ #include "qemu/main-loop.h" #include "qemu/module.h" #include "qemu/hw-version.h" +#include "qemu/memalign.h" #include "hw/scsi/scsi.h" #include "migration/qemu-file-types.h" #include "migration/vmstate.h" diff --git a/hw/tpm/tpm_ppi.c b/hw/tpm/tpm_ppi.c index 6dbb9f41e40..c89ac53e65e 100644 --- a/hw/tpm/tpm_ppi.c +++ b/hw/tpm/tpm_ppi.c @@ -12,7 +12,7 @@ */ #include "qemu/osdep.h" - +#include "qemu/memalign.h" #include "qapi/error.h" #include "sysemu/memory_mapping.h" #include "migration/vmstate.h" diff --git a/nbd/server.c b/nbd/server.c index 9fb2f264023..53e68cf027f 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -25,6 +25,7 @@ #include "trace.h" #include "nbd-internal.h" #include "qemu/units.h" +#include "qemu/memalign.h" #define NBD_META_ID_BASE_ALLOCATION 0 #define NBD_META_ID_ALLOCATION_DEPTH 1 diff --git a/net/l2tpv3.c b/net/l2tpv3.c index e4d4218db69..b8faa8796c8 100644 --- a/net/l2tpv3.c +++ b/net/l2tpv3.c @@ -34,7 +34,7 @@ #include "qemu/sockets.h" #include "qemu/iov.h" #include "qemu/main-loop.h" - +#include "qemu/memalign.h" /* The buffer size needs to be investigated for optimum numbers and * optimum means of paging in on different systems. This size is diff --git a/plugins/loader.c b/plugins/loader.c index 4883b0a1cbc..88c30bde2d6 100644 --- a/plugins/loader.c +++ b/plugins/loader.c @@ -27,6 +27,7 @@ #include "qemu/cacheinfo.h" #include "qemu/xxhash.h" #include "qemu/plugin.h" +#include "qemu/memalign.h" #include "hw/core/cpu.h" #include "exec/exec-all.h" #ifndef CONFIG_USER_ONLY diff --git a/qemu-img.c b/qemu-img.c index 6fe2466032f..5dffb3e6160 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -42,6 +42,7 @@ #include "qemu/module.h" #include "qemu/sockets.h" #include "qemu/units.h" +#include "qemu/memalign.h" #include "qom/object_interfaces.h" #include "sysemu/block-backend.h" #include "block/block_int.h" diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 46593d632d8..633b46cdb25 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -21,6 +21,7 @@ #include "qemu/option.h" #include "qemu/timer.h" #include "qemu/cutils.h" +#include "qemu/memalign.h" #define CMD_NOFILE_OK 0x01 diff --git a/qom/object.c b/qom/object.c index 9f7a33139d4..4048a2fef1e 100644 --- a/qom/object.c +++ b/qom/object.c @@ -16,6 +16,7 @@ #include "qom/object.h" #include "qom/object_interfaces.h" #include "qemu/cutils.h" +#include "qemu/memalign.h" #include "qapi/visitor.h" #include "qapi/string-input-visitor.h" #include "qapi/string-output-visitor.h" diff --git a/softmmu/physmem.c b/softmmu/physmem.c index a13289a594a..59dcf13faf4 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -42,6 +42,7 @@ #include "qemu/config-file.h" #include "qemu/error-report.h" #include "qemu/qemu-print.h" +#include "qemu/memalign.h" #include "exec/memory.h" #include "exec/ioport.h" #include "sysemu/dma.h" diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 4ba6e82fab3..fc12c02fb21 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -49,6 +49,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/error-report.h" +#include "qemu/memalign.h" #include "sysemu/hvf.h" #include "sysemu/hvf_int.h" diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 2c8feb4a6f7..83d09883020 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -37,6 +37,7 @@ #include "qemu/main-loop.h" #include "qemu/config-file.h" #include "qemu/error-report.h" +#include "qemu/memalign.h" #include "hw/i386/x86.h" #include "hw/i386/apic.h" #include "hw/i386/apic_internal.h" diff --git a/tcg/region.c b/tcg/region.c index 72afb357389..97ca5291d52 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -26,6 +26,7 @@ #include "qemu/units.h" #include "qemu/madvise.h" #include "qemu/mprotect.h" +#include "qemu/memalign.h" #include "qemu/cacheinfo.h" #include "qapi/error.h" #include "exec/exec-all.h" diff --git a/tests/bench/atomic_add-bench.c b/tests/bench/atomic_add-bench.c index f05471ab45c..8a6faad6ece 100644 --- a/tests/bench/atomic_add-bench.c +++ b/tests/bench/atomic_add-bench.c @@ -2,6 +2,7 @@ #include "qemu/thread.h" #include "qemu/host-utils.h" #include "qemu/processor.h" +#include "qemu/memalign.h" struct thread_info { uint64_t r; diff --git a/tests/bench/qht-bench.c b/tests/bench/qht-bench.c index 2e5b70ccd04..8afe161d106 100644 --- a/tests/bench/qht-bench.c +++ b/tests/bench/qht-bench.c @@ -10,6 +10,7 @@ #include "qemu/qht.h" #include "qemu/rcu.h" #include "qemu/xxhash.h" +#include "qemu/memalign.h" struct thread_stats { size_t rd; diff --git a/util/atomic64.c b/util/atomic64.c index 22983a970f1..c20d071d8e5 100644 --- a/util/atomic64.c +++ b/util/atomic64.c @@ -8,6 +8,7 @@ #include "qemu/atomic.h" #include "qemu/thread.h" #include "qemu/cacheinfo.h" +#include "qemu/memalign.h" #ifdef CONFIG_ATOMIC64 #error This file must only be compiled if !CONFIG_ATOMIC64 diff --git a/util/memalign.c b/util/memalign.c index 440b8fd9a76..c199ae70732 100644 --- a/util/memalign.c +++ b/util/memalign.c @@ -26,6 +26,7 @@ #include "qemu/osdep.h" #include "qemu/host-utils.h" +#include "qemu/memalign.h" #include "trace.h" void *qemu_try_memalign(size_t alignment, size_t size) diff --git a/util/qht.c b/util/qht.c index 079605121b1..065fc501f44 100644 --- a/util/qht.c +++ b/util/qht.c @@ -69,6 +69,7 @@ #include "qemu/qht.h" #include "qemu/atomic.h" #include "qemu/rcu.h" +#include "qemu/memalign.h" //#define QHT_DEBUG From patchwork Mon Mar 7 16:47:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548875 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1094013wrl; Mon, 7 Mar 2022 08:52:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrbrAoke/nJ1aO5sHEFowYX0p/9XbUtgVuFBu+C40pSApvwQ0ftdDdrpra0lSWokMDStpL X-Received: by 2002:a81:848e:0:b0:2dc:1f07:948d with SMTP id u136-20020a81848e000000b002dc1f07948dmr8980969ywf.434.1646671972658; Mon, 07 Mar 2022 08:52:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646671972; cv=none; d=google.com; s=arc-20160816; b=v/5OyooeYU6T9ZDGDNKs12mr3FeRdSk0Ssv8eOvOEs+n2GGT24SGR6zJl+9TZ4JfIU NSYYyY5qNqgWQo7pxTLUoaQh+E4k+dUpWMJZ+yFoIJdROTlGkbevJ2a9jikjAMkGpssB vzTxJJGF0vNW2OG/SbG0AG4VuyQeHAKHD4vQEk1UjwiH182wfZoplYi3elWwd3m3+YxB PHV0VqrLc6sL6p9jjkNJhE5cqUh4qksn8KO2jA531XJOSIhi8c/Ml0baESwFSBEjShba Oy46IDnMQ0fYGYnTX/L5MWLetnrQvY0YlBQl8nP3KvX/dfsbCSuGZ+A8KlyLyQKeOrl0 ShJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=uwF139MRa/ui3lWjCgZadSTEZfoUO9damBLTd17IfOk=; b=Xvb7dP0WGsSqOsnBQQlbO5fOgKonBkxZ99vRnuBX/Qg873ir+SniD5t91+7qDc/L0n nOEqKonDnBcoHMN8Dp/YU/HYfcyEhqwO3tHCNw+2xRR6AP5u3S2p2bO1x4Ak45kaz3iv 0FyiM4eCOcgnirKgj3qDsXbr/Clt0PPlTMllr6M3JyO2BYmNWQul9QigFwKVHwkbS9zy w5FjUTKa91QYs3z79kSbI0CQ+ZTCE6ME/Tz56i/UtjG9+3s4os7sqrP/pOBoRGQpSbdj G5IeBE8Tsn7uuSV9clHgqi3ftayAkTwkbPRBidOBUPIfW9WwywxEsHbxRPfrOZzk4P9l QkbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o3RMUUxi; 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 p4-20020a056902114400b006299be3a4e7si568222ybu.164.2022.03.07.08.52.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:52:52 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o3RMUUxi; 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]:48598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGbM-0003kA-4J for patch@linaro.org; Mon, 07 Mar 2022 11:52:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGW2-0001cm-KZ for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:22 -0500 Received: from [2a00:1450:4864:20::32d] (port=54005 helo=mail-wm1-x32d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGW1-0007ka-0s for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:22 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 19so9301644wmy.3 for ; Mon, 07 Mar 2022 08:47:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=uwF139MRa/ui3lWjCgZadSTEZfoUO9damBLTd17IfOk=; b=o3RMUUxiOJv65VQuPTkA4plC6vqEKnqwELwGthRYYsMOb97IeZG5r8HkHsrk19WPrC pL85KVuCV6EJQ/GljECP0JNKWi96ascudzorEQxl1K+uD5Ts07BJfBzR00+Zq4FFpUGW gjZO8/gNhQchtMzzBKvC1gzw0DLLojbhTefdlPzipWMeJLswaDWu7MnM2KBFO4zE9YNO ATEwYr998+ZWH/lt4CE72I8MpplbzJH/I92FDFNSyjgSS6TMlRM004lMu3dSH2MeDLZY t+4EX/Pw/g8tt0uDlZJHNImE3yG5OPdDdc+gC0dm/3UlV9Ep1/VN5FIJrLYhmwPuhjPF ebgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uwF139MRa/ui3lWjCgZadSTEZfoUO9damBLTd17IfOk=; b=IANND6hb/w76F8edJxutdcrIu3h72JNSMnabjIOLm8LDE4Ily25ZmNgeic6jD9h7QP iSsQqB0fwxbdquLK0qvrZYEdXroYMmFaDyrqJb/jsfaoJHFKpQTo49YAMNCvF7tiQ2d4 h4laDJhMX19nooz8Jqfo6dETh/8hW4itYGKTSLWgqe3MpDhH376eim8CfBOyPZkJYg8j H7AMbOoUKifXLcz6kT2BzSD6P6Sj8kw17+rd2U+ddAidFeLkC3rCD/rMxycPpAqZIzFV tIlqZKtgxLdVoPWpBWOCGkkuKIWUeoRtas6Fw2z6X+/f11kB+VC6pVfaNuoO9C1JMAtL i1ew== X-Gm-Message-State: AOAM531Pt/wzQVXy7MR5fLnv1a7TA8GMv40cmMSS6OpW70TJU1aIxQGf YtltpxH8HVZz9dAQsBvMmOPDvaqg9BuoqQ== X-Received: by 2002:a05:600c:4e56:b0:389:bc4e:6ffb with SMTP id e22-20020a05600c4e5600b00389bc4e6ffbmr2223398wmq.63.1646671639710; Mon, 07 Mar 2022 08:47:19 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:19 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 09/18] target/arm/translate-neon: UNDEF if VLD1/VST1 stride bits are non-zero Date: Mon, 7 Mar 2022 16:47:00 +0000 Message-Id: <20220307164709.2503250-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32d (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For VLD1/VST1 (single element to one lane) we are only accessing one register, and so the 'stride' is meaningless. The bits that would specify stride (insn bit [4] for size=1, bit [6] for size=2) are specified to be zero in the encoding (which would correspond to a stride of 1 for VLD2/VLD3/VLD4 etc), and we must UNDEF if they are not. We failed to make this check, which meant that we would incorrectly handle some instruction patterns as loads or stores instead of UNDEFing them. Enforce that stride == 1 for the nregs == 1 case. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/890 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Tested-by: Richard Henderson Message-id: 20220303113741.2156877-2-peter.maydell@linaro.org --- target/arm/translate-neon.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c index 3854dd35163..072fdc1e6ee 100644 --- a/target/arm/translate-neon.c +++ b/target/arm/translate-neon.c @@ -657,6 +657,9 @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) /* Catch the UNDEF cases. This is unavoidably a bit messy. */ switch (nregs) { case 1: + if (a->stride != 1) { + return false; + } if (((a->align & (1 << a->size)) != 0) || (a->size == 2 && (a->align == 1 || a->align == 2))) { return false; From patchwork Mon Mar 7 16:47:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548877 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1094928wrl; Mon, 7 Mar 2022 08:54:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhBA/jtjgMu7bRD+vuU/rM8izHBJSlDNaizQS5FrM9OblqdYlUY5VuCEu3M3yonzCNTB3D X-Received: by 2002:a0d:d752:0:b0:2d8:1c68:47e with SMTP id z79-20020a0dd752000000b002d81c68047emr9040388ywd.123.1646672060622; Mon, 07 Mar 2022 08:54:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646672060; cv=none; d=google.com; s=arc-20160816; b=eCwl6x02URH2mU6dDvUg0jKsLMW76SqmM8Tfhro6vdhqBikvu34l9JLWF47+ZzO3yN SPv3CpNI4zlM2uKvFEZ4kkDON1QUeboUBGh/WUJjd7vMFd4R7AEIpnb3e3drZBAjZUWp BTLS6n8EL7EkRISuPL/DZWZhaB5vPKcw2tAA/pbXlaxznKJHR5NQbsGcc8MFQuX4+H4M eNr6IE6YFQeP0mqdGre93jZZoBc8h6jRarSdFJ250aEsrTleDYXkWVUV8hs49ygedDY4 C0Iz84Rm6qAyHB0ddySswxXjl2d4i89/zuaUftcbIqavpFPJNJx5XDomuha1pjwuY7gh wonw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=cuM6/+p90e9wLyBjLSQA/Njnuwiyeuurw2dGmJV2SRg=; b=pMRucv36ZCJdQCldIDxu716CGh99xQ+FzXH8swpXtWd3tDYmBIOEZwV81XsZAigT5n JCmW2zl7V3mpq51wBHIx1Z/BdPOI+XTGwiMeZI8bxSseVnDEw+YTseFr1+R/W+qcVa9k eomhRdDRyyeUnt29isWDlgqvBpcDi2ojw6uG9qdEDtdinnPxLShoaiZ7xSjonlesTF0m QaCayh++XxnEgdyIe0b9wYaL+oJExxXeImudbG3ZpXE2QJ/lkCybjNenn9WFRWqUdSwy 8ZSksQWlD7E2fzCrrgLJ7uKRbxeEFvYyUTKN0kBm8oZByCFHu4wYJY/y+mONNO3sTXPY qgHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MOllhC7T; 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 m13-20020a81c70d000000b002d644b6f333si9123932ywi.127.2022.03.07.08.54.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:54:20 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MOllhC7T; 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]:55008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGcl-0007yG-Ty for patch@linaro.org; Mon, 07 Mar 2022 11:54:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGW3-0001fr-9y for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:23 -0500 Received: from [2a00:1450:4864:20::42c] (port=41971 helo=mail-wr1-x42c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGW1-0007km-Pu for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:23 -0500 Received: by mail-wr1-x42c.google.com with SMTP id i8so24262095wrr.8 for ; Mon, 07 Mar 2022 08:47:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=cuM6/+p90e9wLyBjLSQA/Njnuwiyeuurw2dGmJV2SRg=; b=MOllhC7TI+Mxey5Cl0jmwWdbv25DDA81Z/5GU+DSJocmnSwcvx4Mti+zVkrpkoGuyI zAZyw9VhMIkvrA0T7gU4zez/ox3pYrQ2xI2vK4+l8QsQjqFguv+RtDthaKcIxr7oT7J0 WJUtF9WOxHNqwOTxHT9ja2OZJgAwETBy77IObgolt6Hn0x4w129+h9WWPwfFEYjnPcry MQWlFnQlY2t3WRyboXjZ0i7NRdm5JzhawRWMe2ZCCa5OiZ76bcbi+bQkZFuzz800AaKC HjFPbb76OltewSW76Mk1kvMCtSFRCzcoesqmryRy9qLS88le4OeMKPrADBLKJ2Mmc8gG Q6LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cuM6/+p90e9wLyBjLSQA/Njnuwiyeuurw2dGmJV2SRg=; b=Zhp032pVODN/qErYbw6TklS33tqqM90HnXX1H6YaJUo49cStVU/Qn3RxcKi42G3Tuo ZKuIMdQFEgnvbeN2L0Hl7GtfE8uP413mfmPinTOnG5/0QclcfhssN1Aeur2Nzj6pknay LDB8+0dPYNRUv4aI0M26n2D1mHfmO0MB0qlU30V2wVqXDq7KIfZdK2/nEwmXIM4lVe9T hvQIsoLTSna4HhK9not5QfBAWShGOc3XC6qKL8B9hXEyf4hEvqKQ9ezhrNcKCKVftagj AlZGkDjvbJK/g0nf23VLGQqP9P0OlbViHPzW/I6w9F1TDKTMime6md50Mt8zraR1R69v +B7w== X-Gm-Message-State: AOAM5302+OoKHzfoYbYYHpvyO9473wZMaw2NCsGd1IbFbeB0RA8ehvWB dfCDCsLSVzt44b35U1fQT3viGcEJi4avUg== X-Received: by 2002:a5d:47c5:0:b0:1ef:f2e8:11fc with SMTP id o5-20020a5d47c5000000b001eff2e811fcmr8670979wrc.109.1646671640502; Mon, 07 Mar 2022 08:47:20 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:20 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 10/18] target/arm/translate-neon: Simplify align field check for VLD3 Date: Mon, 7 Mar 2022 16:47:01 +0000 Message-Id: <20220307164709.2503250-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42c (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For VLD3 (single 3-element structure to one lane), there is no alignment specification and the alignment bits in the instruction must be zero. This is bit [4] for the size=0 and size=1 cases, and bits [5:4] for the size=2 case. We do this check correctly in VLDST_single(), but we write it a bit oddly: in the 'case 3' code we check for bit 0 of a->align (bit [4] of the insn), and then we fall through to the 'case 2' code which checks bit 1 of a->align (bit [5] of the insn) in the size 2 case. Replace this with just checking "is a->align non-zero" for VLD3, which lets us drop the fall-through and put the cases in this switch in numerical order. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Tested-by: Richard Henderson Message-id: 20220303113741.2156877-3-peter.maydell@linaro.org --- target/arm/translate-neon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c index 072fdc1e6ee..384604c0095 100644 --- a/target/arm/translate-neon.c +++ b/target/arm/translate-neon.c @@ -665,16 +665,16 @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) return false; } break; - case 3: - if ((a->align & 1) != 0) { - return false; - } - /* fall through */ case 2: if (a->size == 2 && (a->align & 2) != 0) { return false; } break; + case 3: + if (a->align != 0) { + return false; + } + break; case 4: if (a->size == 2 && a->align == 3) { return false; From patchwork Mon Mar 7 16:47:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548873 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1092361wrl; Mon, 7 Mar 2022 08:50:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjWkSIGGm/DpwnDKYp5srnD+1WD5RUbzYFLFf9STv7BxgV93oS3B/6voTKipsuFxlbP3PP X-Received: by 2002:a25:d907:0:b0:629:4436:f506 with SMTP id q7-20020a25d907000000b006294436f506mr4703470ybg.226.1646671806385; Mon, 07 Mar 2022 08:50:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646671806; cv=none; d=google.com; s=arc-20160816; b=vZNf/xxh72wuglo0xERZvGEqz0TgJYJ/ZHSzYo4X3sZ93iUNvUP3oEYHlToOwyG1cR zLTOZjEobunTArlXIogq5+jtU9TwHR/42LRNGH6xnSKOZxHhWwbcn3SShVdBND6oKnAI NYZELcdieqzJcnUhkh0VzUkuvLCzFI5Rly256g2rVdUZWlNfqUuCVDY2WkwOnt1i8GMp jeiUUAmQ9ZXQxLvuHIb0NcIW4DlbWCEfC27u00Y9Cm366imwzo3CuU/tMtuhha/3zLdb eDLW19ooffRyGzxbOF3U7H+sk5EHvn6rv4Ct0sMivNDfNFfwGUFfpovLjyL2MMY/nSrR AV+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=rTX2jK+IjrpdOkaSjScoBgbhdOK2PtRbSfSVbqxnH7w=; b=g23YENFdRgL/uKHmGAk8ptLIyOU3qNQGw0aHDUMWwx7T9EB4z9bm2uE0G3XYeZTzhb SI0ucFKngPr7xZoW5GvcpPxBHQZ4EE7vwqHYaypNRjOLVf+N/fC/sYhuPjVQ7anhH3Vp goGsJjRYq2YmHVs8M4+y6XVE4oRN4aTbgHyprRf4VXC6AaZI9yUNbSz/bqBg0WEoxvug dE5UkSxbAHU+Ovp+gEx/ZqwjXmxdawp+X/fNgdscquNUmsi8p7qO/V3sCWffkyLoy+YF kl42DpV1BEUx7GVp/e1Gvo/jOmKKJ/vK901Pm899zUgymLQHKUXxulnvaSlE/gv3ezwo LmQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Agr+lCbu; 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 64-20020a811543000000b002dca3e2660esi3212979ywv.456.2022.03.07.08.50.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:50:06 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Agr+lCbu; 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]:41154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGYd-0007Ar-5Q for patch@linaro.org; Mon, 07 Mar 2022 11:50:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGW4-0001kW-H4 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:24 -0500 Received: from [2a00:1450:4864:20::429] (port=40744 helo=mail-wr1-x429.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGW2-0007kv-Kj for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:24 -0500 Received: by mail-wr1-x429.google.com with SMTP id k24so14822941wrd.7 for ; Mon, 07 Mar 2022 08:47:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=rTX2jK+IjrpdOkaSjScoBgbhdOK2PtRbSfSVbqxnH7w=; b=Agr+lCbuFecOueyYbqoM+Rf1EdZSsdnSkVH+4JHQIlyThzzf5dq/Z9xkQ280wT01PK YLlCoPY1HMEswDOyiVbmbODUU9NxfeDl751LpMK7IexLh+mUKj4067qgZnX/qAQVt7g9 ErlUrBWXs25bY2aCALhjee0BiHznm5mg0at+qrm2gd9uZTvmow3Y0NgsYUiNKHd3RkyB pRqI+A6EpLeG74rrHvEFKEcYKyRSRX3mNDtq84ItWwZKAUA1XCOBS9yMPnLokj9F0gqD Ibq+qxF/0RhtzNNTu0gDmaZ4y6+Ph55YoU68BmJLbbr+Viau8NNTw8m2VNJXXnOzbELL XHfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rTX2jK+IjrpdOkaSjScoBgbhdOK2PtRbSfSVbqxnH7w=; b=K6pw1kj4FZsjPjvjD7P9cEH/v4nWU4CYyqCA5MJC2PuZhXixUtbjy1mC5bzqeAIVbl HfdJeXzuKpa0v1wEBHNHMh9hwVO1j6o/V1MrksCAFPQvaEXBCP9PfYmI04/nE1Sk9zC0 K0OSZBi+xytI8iCwSbgGGCmOh6waHVFSCiMMR4QYQ3dKnpyTtNDpuQuii/mwMb2B+mKP qh7wX+23+ZvkKxPhnskpOM9a8Qh/arDgZ50ZjUtlMiHqN6bt9/dkFDN/J8R9z+eUD9tV MR3Gwrs64u4XNysXoC9VXCey2o6jWmk1th+n+BauOSZRCuB6jHpvgW+32C/toRUj5Fp8 F36w== X-Gm-Message-State: AOAM533Lb+il8kXgWnmSeqkKTSyvyXgRak5jIhRSyupLZnfBNVn5PxAc 7lpA2joSBguc/gmSSJpSs0I8edvUgAAhWw== X-Received: by 2002:a05:6000:168e:b0:1f1:faee:f1c4 with SMTP id y14-20020a056000168e00b001f1faeef1c4mr3067576wrd.173.1646671641372; Mon, 07 Mar 2022 08:47:21 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:21 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/18] hw/intc/arm_gicv3_its: Add trace events for commands Date: Mon, 7 Mar 2022 16:47:02 +0000 Message-Id: <20220307164709.2503250-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::429 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When debugging code that's using the ITS, it's helpful to see tracing of the ITS commands that the guest executes. Add suitable trace events. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20220303202341.2232284-2-peter.maydell@linaro.org --- hw/intc/arm_gicv3_its.c | 28 ++++++++++++++++++++++++++-- hw/intc/trace-events | 12 ++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c index 4f598d3c14f..77dc702734b 100644 --- a/hw/intc/arm_gicv3_its.c +++ b/hw/intc/arm_gicv3_its.c @@ -366,6 +366,19 @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, const uint64_t *cmdpkt, devid = (cmdpkt[0] & DEVID_MASK) >> DEVID_SHIFT; eventid = cmdpkt[1] & EVENTID_MASK; + switch (cmd) { + case INTERRUPT: + trace_gicv3_its_cmd_int(devid, eventid); + break; + case CLEAR: + trace_gicv3_its_cmd_clear(devid, eventid); + break; + case DISCARD: + trace_gicv3_its_cmd_discard(devid, eventid); + break; + default: + g_assert_not_reached(); + } return do_process_its_cmd(s, devid, eventid, cmd); } @@ -382,15 +395,16 @@ static ItsCmdResult process_mapti(GICv3ITSState *s, const uint64_t *cmdpkt, devid = (cmdpkt[0] & DEVID_MASK) >> DEVID_SHIFT; eventid = cmdpkt[1] & EVENTID_MASK; + icid = cmdpkt[2] & ICID_MASK; if (ignore_pInt) { pIntid = eventid; + trace_gicv3_its_cmd_mapi(devid, eventid, icid); } else { pIntid = (cmdpkt[1] & pINTID_MASK) >> pINTID_SHIFT; + trace_gicv3_its_cmd_mapti(devid, eventid, icid, pIntid); } - icid = cmdpkt[2] & ICID_MASK; - if (devid >= s->dt.num_entries) { qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid command attributes: devid %d>=%d", @@ -484,6 +498,7 @@ static ItsCmdResult process_mapc(GICv3ITSState *s, const uint64_t *cmdpkt) } else { cte.rdbase = 0; } + trace_gicv3_its_cmd_mapc(icid, cte.rdbase, cte.valid); if (icid >= s->ct.num_entries) { qemu_log_mask(LOG_GUEST_ERROR, "ITS MAPC: invalid ICID 0x%d", icid); @@ -539,6 +554,8 @@ static ItsCmdResult process_mapd(GICv3ITSState *s, const uint64_t *cmdpkt) dte.ittaddr = (cmdpkt[2] & ITTADDR_MASK) >> ITTADDR_SHIFT; dte.valid = cmdpkt[2] & CMD_FIELD_VALID_MASK; + trace_gicv3_its_cmd_mapd(devid, dte.size, dte.ittaddr, dte.valid); + if (devid >= s->dt.num_entries) { qemu_log_mask(LOG_GUEST_ERROR, "ITS MAPD: invalid device ID field 0x%x >= 0x%x\n", @@ -562,6 +579,8 @@ static ItsCmdResult process_movall(GICv3ITSState *s, const uint64_t *cmdpkt) rd1 = FIELD_EX64(cmdpkt[2], MOVALL_2, RDBASE1); rd2 = FIELD_EX64(cmdpkt[3], MOVALL_3, RDBASE2); + trace_gicv3_its_cmd_movall(rd1, rd2); + if (rd1 >= s->gicv3->num_cpu) { qemu_log_mask(LOG_GUEST_ERROR, "%s: RDBASE1 %" PRId64 @@ -601,6 +620,8 @@ static ItsCmdResult process_movi(GICv3ITSState *s, const uint64_t *cmdpkt) eventid = FIELD_EX64(cmdpkt[1], MOVI_1, EVENTID); new_icid = FIELD_EX64(cmdpkt[2], MOVI_2, ICID); + trace_gicv3_its_cmd_movi(devid, eventid, new_icid); + if (devid >= s->dt.num_entries) { qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid command attributes: devid %d>=%d", @@ -779,6 +800,7 @@ static void process_cmdq(GICv3ITSState *s) * is already consistent by the time SYNC command is executed. * Hence no further processing is required for SYNC command. */ + trace_gicv3_its_cmd_sync(); break; case GITS_CMD_MAPD: result = process_mapd(s, cmdpkt); @@ -803,6 +825,7 @@ static void process_cmdq(GICv3ITSState *s) * need to trigger lpi priority re-calculation to be in * sync with LPI config table or pending table changes. */ + trace_gicv3_its_cmd_inv(); for (i = 0; i < s->gicv3->num_cpu; i++) { gicv3_redist_update_lpi(&s->gicv3->cpu[i]); } @@ -814,6 +837,7 @@ static void process_cmdq(GICv3ITSState *s) result = process_movall(s, cmdpkt); break; default: + trace_gicv3_its_cmd_unknown(cmd); break; } if (result == CMD_CONTINUE) { diff --git a/hw/intc/trace-events b/hw/intc/trace-events index b28cda4e08e..e92662b405c 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -176,6 +176,18 @@ gicv3_its_write(uint64_t offset, uint64_t data, unsigned size) "GICv3 ITS write: gicv3_its_badwrite(uint64_t offset, uint64_t data, unsigned size) "GICv3 ITS write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u: error" gicv3_its_translation_write(uint64_t offset, uint64_t data, unsigned size, uint32_t requester_id) "GICv3 ITS TRANSLATER write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u requester_id 0x%x" gicv3_its_process_command(uint32_t rd_offset, uint8_t cmd) "GICv3 ITS: processing command at offset 0x%x: 0x%x" +gicv3_its_cmd_int(uint32_t devid, uint32_t eventid) "GICv3 ITS: command INT DeviceID 0x%x EventID 0x%x" +gicv3_its_cmd_clear(uint32_t devid, uint32_t eventid) "GICv3 ITS: command CLEAR DeviceID 0x%x EventID 0x%x" +gicv3_its_cmd_discard(uint32_t devid, uint32_t eventid) "GICv3 ITS: command DISCARD DeviceID 0x%x EventID 0x%x" +gicv3_its_cmd_sync(void) "GICv3 ITS: command SYNC" +gicv3_its_cmd_mapd(uint32_t devid, uint32_t size, uint64_t ittaddr, int valid) "GICv3 ITS: command MAPD DeviceID 0x%x Size 0x%x ITT_addr 0x%" PRIx64 " V %d" +gicv3_its_cmd_mapc(uint32_t icid, uint64_t rdbase, int valid) "GICv3 ITS: command MAPC ICID 0x%x RDbase 0x%" PRIx64 " V %d" +gicv3_its_cmd_mapi(uint32_t devid, uint32_t eventid, uint32_t icid) "GICv3 ITS: command MAPI DeviceID 0x%x EventID 0x%x ICID 0x%x" +gicv3_its_cmd_mapti(uint32_t devid, uint32_t eventid, uint32_t icid, uint32_t intid) "GICv3 ITS: command MAPTI DeviceID 0x%x EventID 0x%x ICID 0x%x pINTID 0x%x" +gicv3_its_cmd_inv(void) "GICv3 ITS: command INV or INVALL" +gicv3_its_cmd_movall(uint64_t rd1, uint64_t rd2) "GICv3 ITS: command MOVALL RDbase1 0x%" PRIx64 " RDbase2 0x%" PRIx64 +gicv3_its_cmd_movi(uint32_t devid, uint32_t eventid, uint32_t icid) "GICv3 ITS: command MOVI DeviceID 0x%x EventID 0x%x ICID 0x%x" +gicv3_its_cmd_unknown(unsigned cmd) "GICv3 ITS: unknown command 0x%x" # armv7m_nvic.c nvic_recompute_state(int vectpending, int vectpending_prio, int exception_prio) "NVIC state recomputed: vectpending %d vectpending_prio %d exception_prio %d" From patchwork Mon Mar 7 16:47:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548880 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1095850wrl; Mon, 7 Mar 2022 08:55:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNjLZ51aPBMXY7W5PAtG9O0Ra9MsVC/mHclJjZzBdcNE17CinhIylQ+zKBGWM5f23HisqQ X-Received: by 2002:a0d:ee03:0:b0:2d6:c6cd:d598 with SMTP id x3-20020a0dee03000000b002d6c6cdd598mr9836458ywe.425.1646672140142; Mon, 07 Mar 2022 08:55:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646672140; cv=none; d=google.com; s=arc-20160816; b=rZGYIwbaSzY/5UEx8e5m2QDfAyxGeUVNnPjF4j7/BdS562aZ28k2E18F2IlenEmrR0 94EqquaZeMM+laUiyI68OwgZ3zm+YI5f9v1uhplt47bA91y129dUpgToRu9WfQIPs+bO Y0/8TILus9RbSVw/5d210BYVPzhfRE6vXRLitC1kugYcVSg9DNmTKJNNR37+rDjpQm9e oatBWBBpCHeo94fNNm7Ug0CS4yJlEdYJzOqG9b1RQmjs4tQDhE6mIOtDs3pZQ1CJ4GeU 1mIQaHL2hIsyalbwp2lElmCMBmp+1iOKGI6GX1TrAPdZqsCkWF4Y9PSnpK2b/H5pKi5a xh7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=xPLWOc1ulzWD7BSXwRoC+kifzLTGlELDNs5HJiVO+oQ=; b=Y8eUWYrjOD/jFoEPha2wSyEXznqt0+xEHnCUZFzpRlvyAhQSia2vINte3nonWJknEQ jhyFxeGqRj3nIT67I/nzg94xnrNDv3QNcwLcsBKroUwdEXG8y6o+W418j3IMD0eG0DVn pZGS+bzIEZe6LXcNGqihw7mTYiHor1268yKagceud3CDY407uPGa10WF4rylsXII6yXF kWvOQziBqi5N2TIGkx+HMN/K9d/zyFXQcyN/vILLqltFj4aGwj0/WEuiPCy1xdksVvbv rhpzUiXP5mLVor2ocoIRSSPYI7MEadoYIlTd1H3t3pFu+lgSyqmwfUkD/QaTAp7qX5f8 /9iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qn8tf0s0; 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 z70-20020a0dd749000000b002dc50d10143si7484790ywd.385.2022.03.07.08.55.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:55:40 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qn8tf0s0; 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]:33214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGe3-0003m0-HD for patch@linaro.org; Mon, 07 Mar 2022 11:55:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGW5-0001nP-AT for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:25 -0500 Received: from [2a00:1450:4864:20::42a] (port=40745 helo=mail-wr1-x42a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGW3-0007lG-Jx for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:25 -0500 Received: by mail-wr1-x42a.google.com with SMTP id k24so14823005wrd.7 for ; Mon, 07 Mar 2022 08:47:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=xPLWOc1ulzWD7BSXwRoC+kifzLTGlELDNs5HJiVO+oQ=; b=Qn8tf0s0iP9w00DfxAL7z5ec9TCgcDkpLGsS1+qmyr1ZBlGUut398ybjTRyNU6kVuU hKmd8LHg1K/gUr7Xe68aQYv37sFUzgXxhmf2e7Od+scyLKxXXZ0sR2wCJOzCmBohusWc qa148Kp2BrpLwRsbZWA6x5ZFuCItNonnhn1FExN7mtfw3MeaKHDqqt9oNgAGayAXA0Yj /r5ys4NwEWDucLfdh1IKELMTD+hUFluE14aDeXJF8NV7DQaa+I6nZbyAXFIzIcqIovQw wBdvXniqW71d5wC+fsw54qzuSyS1KYTIl38OdjxCmhgWHY8+PYR7Qg1HVXocYJnoZys/ qAVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xPLWOc1ulzWD7BSXwRoC+kifzLTGlELDNs5HJiVO+oQ=; b=zG4Lk1KNfBNVcrQfzzi0CKaZY14EEDnNa9WQnDxWsYNMLXP6NR4oBKiYhj32zVl8gL 6IEXXHejxg0rGKL3ct3ozI+rz7PEhyDM6KxriFbaIfG/itsmCGx1s0i6Ov6aOab3q/1y KylHgqNPtnPgLUbxB41GkhKVBS/pkUoucu8mWA65+33OWCf0xcEGtrtZd+1H2xYa2tgr RBIZ271d6xl1mONL6M2aOXgYt42yuwXVbHf9Kh+SMDvRo8L31eF7D7J2yKo6+l39EtEw iAhbTteSgDgHKHfkBm3mVsaFlIPn/hPM6bXAtKvrXz7Js8FlMLjNGCHhNra+ibNP35yi 6PlA== X-Gm-Message-State: AOAM533DB/n3vYGi0nF58EA75f4DVPKjpyFvh1/yUd8Kwhhx07hB0B09 VCnCf/R18jXDUFduPeHYx4dO72LaM2N3Gw== X-Received: by 2002:adf:f646:0:b0:1f0:4e5b:f423 with SMTP id x6-20020adff646000000b001f04e5bf423mr9422438wrp.2.1646671642211; Mon, 07 Mar 2022 08:47:22 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:21 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 12/18] hw/intc/arm_gicv3_its: Add trace events for table reads and writes Date: Mon, 7 Mar 2022 16:47:03 +0000 Message-Id: <20220307164709.2503250-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42a (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For debugging guest use of the ITS, it can be helpful to trace when the ITS reads and writes the in-memory tables. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20220303202341.2232284-3-peter.maydell@linaro.org --- hw/intc/arm_gicv3_its.c | 37 +++++++++++++++++++++++++++++++------ hw/intc/trace-events | 9 +++++++++ 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c index 77dc702734b..9f4df6a8cbb 100644 --- a/hw/intc/arm_gicv3_its.c +++ b/hw/intc/arm_gicv3_its.c @@ -161,16 +161,22 @@ static MemTxResult get_cte(GICv3ITSState *s, uint16_t icid, CTEntry *cte) if (entry_addr == -1) { /* No L2 table entry, i.e. no valid CTE, or a memory error */ cte->valid = false; - return res; + goto out; } cteval = address_space_ldq_le(as, entry_addr, MEMTXATTRS_UNSPECIFIED, &res); if (res != MEMTX_OK) { - return res; + goto out; } cte->valid = FIELD_EX64(cteval, CTE, VALID); cte->rdbase = FIELD_EX64(cteval, CTE, RDBASE); - return MEMTX_OK; +out: + if (res != MEMTX_OK) { + trace_gicv3_its_cte_read_fault(icid); + } else { + trace_gicv3_its_cte_read(icid, cte->valid, cte->rdbase); + } + return res; } /* @@ -187,6 +193,10 @@ static bool update_ite(GICv3ITSState *s, uint32_t eventid, const DTEntry *dte, uint64_t itel = 0; uint32_t iteh = 0; + trace_gicv3_its_ite_write(dte->ittaddr, eventid, ite->valid, + ite->inttype, ite->intid, ite->icid, + ite->vpeid, ite->doorbell); + if (ite->valid) { itel = FIELD_DP64(itel, ITE_L, VALID, 1); itel = FIELD_DP64(itel, ITE_L, INTTYPE, ite->inttype); @@ -221,11 +231,13 @@ static MemTxResult get_ite(GICv3ITSState *s, uint32_t eventid, itel = address_space_ldq_le(as, iteaddr, MEMTXATTRS_UNSPECIFIED, &res); if (res != MEMTX_OK) { + trace_gicv3_its_ite_read_fault(dte->ittaddr, eventid); return res; } iteh = address_space_ldl_le(as, iteaddr + 8, MEMTXATTRS_UNSPECIFIED, &res); if (res != MEMTX_OK) { + trace_gicv3_its_ite_read_fault(dte->ittaddr, eventid); return res; } @@ -235,6 +247,9 @@ static MemTxResult get_ite(GICv3ITSState *s, uint32_t eventid, ite->icid = FIELD_EX64(itel, ITE_L, ICID); ite->vpeid = FIELD_EX64(itel, ITE_L, VPEID); ite->doorbell = FIELD_EX64(iteh, ITE_H, DOORBELL); + trace_gicv3_its_ite_read(dte->ittaddr, eventid, ite->valid, + ite->inttype, ite->intid, ite->icid, + ite->vpeid, ite->doorbell); return MEMTX_OK; } @@ -254,17 +269,23 @@ static MemTxResult get_dte(GICv3ITSState *s, uint32_t devid, DTEntry *dte) if (entry_addr == -1) { /* No L2 table entry, i.e. no valid DTE, or a memory error */ dte->valid = false; - return res; + goto out; } dteval = address_space_ldq_le(as, entry_addr, MEMTXATTRS_UNSPECIFIED, &res); if (res != MEMTX_OK) { - return res; + goto out; } dte->valid = FIELD_EX64(dteval, DTE, VALID); dte->size = FIELD_EX64(dteval, DTE, SIZE); /* DTE word field stores bits [51:8] of the ITT address */ dte->ittaddr = FIELD_EX64(dteval, DTE, ITTADDR) << ITTADDR_SHIFT; - return MEMTX_OK; +out: + if (res != MEMTX_OK) { + trace_gicv3_its_dte_read_fault(devid); + } else { + trace_gicv3_its_dte_read(devid, dte->valid, dte->size, dte->ittaddr); + } + return res; } /* @@ -465,6 +486,8 @@ static bool update_cte(GICv3ITSState *s, uint16_t icid, const CTEntry *cte) uint64_t cteval = 0; MemTxResult res = MEMTX_OK; + trace_gicv3_its_cte_write(icid, cte->valid, cte->rdbase); + if (cte->valid) { /* add mapping entry to collection table */ cteval = FIELD_DP64(cteval, CTE, VALID, 1); @@ -524,6 +547,8 @@ static bool update_dte(GICv3ITSState *s, uint32_t devid, const DTEntry *dte) uint64_t dteval = 0; MemTxResult res = MEMTX_OK; + trace_gicv3_its_dte_write(devid, dte->valid, dte->size, dte->ittaddr); + if (dte->valid) { /* add mapping entry to device table */ dteval = FIELD_DP64(dteval, DTE, VALID, 1); diff --git a/hw/intc/trace-events b/hw/intc/trace-events index e92662b405c..53414aa1979 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -188,6 +188,15 @@ gicv3_its_cmd_inv(void) "GICv3 ITS: command INV or INVALL" gicv3_its_cmd_movall(uint64_t rd1, uint64_t rd2) "GICv3 ITS: command MOVALL RDbase1 0x%" PRIx64 " RDbase2 0x%" PRIx64 gicv3_its_cmd_movi(uint32_t devid, uint32_t eventid, uint32_t icid) "GICv3 ITS: command MOVI DeviceID 0x%x EventID 0x%x ICID 0x%x" gicv3_its_cmd_unknown(unsigned cmd) "GICv3 ITS: unknown command 0x%x" +gicv3_its_cte_read(uint32_t icid, int valid, uint32_t rdbase) "GICv3 ITS: Collection Table read for ICID 0x%x: valid %d RDBase 0x%x" +gicv3_its_cte_write(uint32_t icid, int valid, uint32_t rdbase) "GICv3 ITS: Collection Table write for ICID 0x%x: valid %d RDBase 0x%x" +gicv3_its_cte_read_fault(uint32_t icid) "GICv3 ITS: Collection Table read for ICID 0x%x: faulted" +gicv3_its_ite_read(uint64_t ittaddr, uint32_t eventid, int valid, int inttype, uint32_t intid, uint32_t icid, uint32_t vpeid, uint32_t doorbell) "GICv3 ITS: Interrupt Table read for ITTaddr 0x%" PRIx64 " EventID 0x%x: valid %d inttype %d intid 0x%x ICID 0x%x vPEID 0x%x doorbell 0x%x" +gicv3_its_ite_read_fault(uint64_t ittaddr, uint32_t eventid) "GICv3 ITS: Interrupt Table read for ITTaddr 0x%" PRIx64 " EventID 0x%x: faulted" +gicv3_its_ite_write(uint64_t ittaddr, uint32_t eventid, int valid, int inttype, uint32_t intid, uint32_t icid, uint32_t vpeid, uint32_t doorbell) "GICv3 ITS: Interrupt Table write for ITTaddr 0x%" PRIx64 " EventID 0x%x: valid %d inttype %d intid 0x%x ICID 0x%x vPEID 0x%x doorbell 0x%x" +gicv3_its_dte_read(uint32_t devid, int valid, uint32_t size, uint64_t ittaddr) "GICv3 ITS: Device Table read for DeviceID 0x%x: valid %d size 0x%x ITTaddr 0x%" PRIx64 +gicv3_its_dte_write(uint32_t devid, int valid, uint32_t size, uint64_t ittaddr) "GICv3 ITS: Device Table write for DeviceID 0x%x: valid %d size 0x%x ITTaddr 0x%" PRIx64 +gicv3_its_dte_read_fault(uint32_t devid) "GICv3 ITS: Device Table read for DeviceID 0x%x: faulted" # armv7m_nvic.c nvic_recompute_state(int vectpending, int vectpending_prio, int exception_prio) "NVIC state recomputed: vectpending %d vectpending_prio %d exception_prio %d" From patchwork Mon Mar 7 16:47:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548883 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1097227wrl; Mon, 7 Mar 2022 08:57:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVhCfTYm8dAldD4RRhXoDq8lIw+5d7AwgfZIVFNARxcylwvKBHHBwjEVaGwekaU9JiaJIt X-Received: by 2002:a25:d181:0:b0:629:1919:d8e5 with SMTP id i123-20020a25d181000000b006291919d8e5mr7580851ybg.85.1646672274920; Mon, 07 Mar 2022 08:57:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646672274; cv=none; d=google.com; s=arc-20160816; b=psi8xHuZAFFmCNAUxVmJODWVEGZ7IrDVXOdt11mtICO/W/TIPFN/qXVk/FC37q53sM T8k+ctImTbG1R8eyiCWWg4mPmhQSJQBZrQlhDMfOIQQj8Qc5obqm3e0+NXqncBuRpoNp wX6KPr2Q+1lCSRbzJqerBCVKg1Gzc7D5AHhfz42bKaosz07Sd9YdH/1j9t2O0B29KACt RuVLs4qxMqFnj3BWT9oDRCoMpsROvZTaYgohIkaCjis2mnR/FAfrf1Rrhgu9zwzVkBXX 5lU8LuLYS1DsPRzEZ2wMz0I7SeuocYBA/GXZSsq/LmCIDadq4Jqdaf/A0mUIJ4rNrvtj WBxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=k3XXdEEkAT8rtcP4zgQB24XrJWOVDRQK/GtPyU/3Usc=; b=an5lLtfeI7Rj5/alkO4rxTg3OglnslgLB8XURojAnURVSKmnaUn0q2UcznbGgOeYA6 u76C5yJsYsQPIZUGdJbg5YsRMJ12ajV9WRwiFASVXV1hphpt4dQ9iANGXzUkv2WVJSid OfUPaAWskekr7cBxSV0xZLJ3XU8k/zJGq3sefytM1BMW7i6LmosWjy+w/t2t4ksuUOKS /Vlfe9yDuP3LVQSWq6ARTEryV3v6bCL73qG7a+63PSdYORmhFuEu4sTL6uJe6ecLT0Mb 2OUMKuTG5hYdygLOm9zaDtN8OE3S60faDhgH2Gor3CsKCfHihRxoLnYkQvLyuFl0bqWN tvPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qt78X5T3; 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 a196-20020a81a3cd000000b002dbf4269b93si9007807ywh.333.2022.03.07.08.57.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:57:54 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qt78X5T3; 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]:38238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGgE-00071Q-Bn for patch@linaro.org; Mon, 07 Mar 2022 11:57:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGW5-0001pG-T7 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:25 -0500 Received: from [2a00:1450:4864:20::42f] (port=33631 helo=mail-wr1-x42f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGW4-0007lU-8J for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:25 -0500 Received: by mail-wr1-x42f.google.com with SMTP id j17so24367559wrc.0 for ; Mon, 07 Mar 2022 08:47:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=k3XXdEEkAT8rtcP4zgQB24XrJWOVDRQK/GtPyU/3Usc=; b=qt78X5T32qE3+V+QdB9RtVkOR845+/Wnc0L498DnmiZub4fOypKPtmG0LLhOmjgV/U qGxG5vy80ycliH+owJGNW0KW6TI4L6aS22ohN3m6ZsXbpcWnjVgJjAOhFRNwaxZNY5lP rhK5Piqub2JazJaY6icSaKtr2VYFZ1AKwrSdP9kNWYgW4w8WtP/yzq8l+bGhugKGR4Y6 TW2yXQM9XKLBaE1w9eZrMbiIv8g5x+rF7Z7eXyCjOLcnAZq1pt5MTeCfC9ANg0tYfjc1 f9+J7wCh5oxgI6V3/Zptxjbb9G+Z0Xqt9Ez+F4458ZmmK1QCl9pK46/YvmFrHD+hnNBS 3Ojw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k3XXdEEkAT8rtcP4zgQB24XrJWOVDRQK/GtPyU/3Usc=; b=sonNTaJ0rAac+qPe0k7XV8/TLhqzs9E6pATdU7W5jer0gwU90s91fMimCVEy3fb07x 3ApXGQVwOWTdpRNT2gH1pEyl0o8Oj73oQg7AcRZDg4QwOyC7Me79JmB5RQwCjIJ2pfgy nEJWEgikqwUjsZ3PmmNQX+QhTJeLX0xS4Xa7c4YaTQVzKoLG9hFOM71coZD8yOJIvO2+ aNKLx6u5zUqlD6dzRxHUjE5LyjSaEZ3rZDkiK1YhUGK7c5P2KjUIfYx6VCp1YPpX8+OV KKprYfI+UARB0DKj6YzXIIjs2yJ+8I/GayqEr3YUQBBsVZE3VSkPx6t+9eKSiONu8GFq umVQ== X-Gm-Message-State: AOAM531Eh/jdJbe1sAS295kfF5+05UECdxlKDpZWlCceDilxkciqAgIx iAq1cKpHpMhMOA2YOcBh/s5Cj3EsVsbYEg== X-Received: by 2002:adf:ea0f:0:b0:1f0:61f6:c3df with SMTP id q15-20020adfea0f000000b001f061f6c3dfmr8895702wrm.543.1646671642978; Mon, 07 Mar 2022 08:47:22 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:22 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 13/18] hw/intc/arm_gicv3: Specify valid and impl in MemoryRegionOps Date: Mon, 7 Mar 2022 16:47:04 +0000 Message-Id: <20220307164709.2503250-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42f (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The GICv3 has some registers that support byte accesses, and some that support 8-byte accesses. Our TCG implementation implements all of this, switching on the 'size' argument and handling the registers that must support reads of that size while logging an error for attempted accesses to registers that do not support that size access. However we forgot to tell the core memory subsystem about this by specifying the .impl and .valid fields in the MemoryRegionOps struct, so the core was happily simulating 8 byte accesses by combining two 4 byte accesses. This doesn't have much guest-visible effect, since there aren't many 8 byte registers and they all support being written in two 4 byte parts. Set the .impl and .valid fields to say that all sizes from 1 to 8 bytes are both valid and implemented by the device. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20220303202341.2232284-4-peter.maydell@linaro.org --- hw/intc/arm_gicv3.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c index 6d3c8ee231c..0b8f79a1227 100644 --- a/hw/intc/arm_gicv3.c +++ b/hw/intc/arm_gicv3.c @@ -369,11 +369,19 @@ static const MemoryRegionOps gic_ops[] = { .read_with_attrs = gicv3_dist_read, .write_with_attrs = gicv3_dist_write, .endianness = DEVICE_NATIVE_ENDIAN, + .valid.min_access_size = 1, + .valid.max_access_size = 8, + .impl.min_access_size = 1, + .impl.max_access_size = 8, }, { .read_with_attrs = gicv3_redist_read, .write_with_attrs = gicv3_redist_write, .endianness = DEVICE_NATIVE_ENDIAN, + .valid.min_access_size = 1, + .valid.max_access_size = 8, + .impl.min_access_size = 1, + .impl.max_access_size = 8, } }; From patchwork Mon Mar 7 16:47:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548882 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1097031wrl; Mon, 7 Mar 2022 08:57:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyNd9AGi7s9nE9q+rJNF1QaSjHs/sjhvAO1+xCm2ig9abr1MQqWQJqf+XEKI11k3rjN86G X-Received: by 2002:a25:b12:0:b0:628:f44d:d26e with SMTP id 18-20020a250b12000000b00628f44dd26emr8240642ybl.522.1646672252772; Mon, 07 Mar 2022 08:57:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646672252; cv=none; d=google.com; s=arc-20160816; b=CY4zed4lXa9b/EO8+3HnWYtZsjISzppVXcXWQomBrRyg3m78bjejLjDTnqDFJH4Fau G2VCxrFuvJcIvqnDM6xwpRWo3Rh6JxyZAv6lmGYOy+npMZ29JVkpu9upc+qphWDQ1Heh qjgTgPw97Sp/ewQ5OWBuNeg7fqC7anYynVvhST2MWdJW2PADznAy5kl29MtbCrkMMTiJ fhPcpLO1IyQqkGCJT6Li2/H2D2cvTpDBFTSbfeMvaE+vLXbtGLw/9izM83VHBS2vGuPX W+hmRh6zDeCwZzjIw39W5sEKTyhqKNU8rUU/1wpN1EDFN3nRAvVLngaNzW7sOPjVNiSg v0mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=GANdenYBNkwkak0rQWxlFry8Hc7CxTND/movhx4GhWc=; b=OmpAa00nWXW1OOVmlrVEzpwi8AmCvDhqJGyg1vuFaiVYaHeUDoSEPq7pYMlJW7ckxZ mJkV6Oeu3jjrwCCRltchKQ10luKR3c+zHKYzU0wbu9eNH6xRzzkd/dV69gIfkickVLe2 zYuMeHy4FwSh1FWlX23DnDqajzY4jhoV7k+ubpmno2ITTOoy3YPM7tnSsedBI47Bn8+U 0orNxa2+L08CS5+jIRSfmkUpqAi4VFsnCqEAkNrlKGrYGzFAMRTt4O1leBoH7XarsVNK iKdDibB3IMUN2/KLQWd5pX5gV1Xg94gjfqgHWJad2HlSrTFUXFzJwstAl53m8oUelWBo dArg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IKz0htit; 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 h22-20020a816c16000000b002dc2db818d2si8206439ywc.513.2022.03.07.08.57.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:57:32 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IKz0htit; 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]:38168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGfs-0006yj-7o for patch@linaro.org; Mon, 07 Mar 2022 11:57:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGW6-0001tg-Vr for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:27 -0500 Received: from [2a00:1450:4864:20::432] (port=37885 helo=mail-wr1-x432.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGW5-0007lh-An for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:26 -0500 Received: by mail-wr1-x432.google.com with SMTP id q14so8728712wrc.4 for ; Mon, 07 Mar 2022 08:47:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=GANdenYBNkwkak0rQWxlFry8Hc7CxTND/movhx4GhWc=; b=IKz0htit7869nNO9uEz6541f34HfujznBcbW+adLOt29A8h8YwkVg9eczAnQCHlLyl kcotL+qKhh7rgV7Iw0iM5/UkvCM2ljKMDAXhM2fuuhbbKL5gd+/AnFUWY84EZ9UErDfx m39W+nJqhSMHCCjOYUkjKZaCLRXLPu/9A7II3kPjOtxZBytD6E/Fay+XfoBemoYnlAf4 MZ2JujxKEBbZlx++eXa9N5C2q74W5uWcdkxXa3hb/5ATmb4v1xT4hnx6zoOHk0B+dwsH sJq7B29Yenb4YbhA5HZApbx2RDavIn409Cr+k6ljXe7ZSXhC/dnM2V0CjbiIKrE2D2o3 M5Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GANdenYBNkwkak0rQWxlFry8Hc7CxTND/movhx4GhWc=; b=ND+W+04nP0ZUaD1p2/8cqKNKH5a+WpXFICXLCBAHCvNVK1R1jDcKFXPyT0Y1uHXzpd 65dxrV3wBJcQBwta048m7F1hd+jHcufttqxg9Ecv0hAUMQmzOYkPNhsf5/F6m5wojl9s qxD2hT9VZV2WI/drldzyYbdFx6uJ4eJ6hZw7pK7tuPRVGEtH5HdNvwHrTZkFTwPOcXnA dZBSr8sWpkVZH5e152o+2SWv3WCUOvxCVgzkIYlRGLJSYm9Do3bwxIKH7wA2ZBbUf6w3 UShnIg6bhJoZI3jSI3C6PBxs/X1RnK0T+jSqOIHkU/gDDTEIb3mn3ZuHQj6WR/RbylED JufA== X-Gm-Message-State: AOAM5305/sh+P7h5oq4BnQgSyjEjPDLFjkLWwjO0m1/Vw52VU03qjF1L 2+ZHUSOUi5+90cb43wmSVy4+2M6DjxB5jg== X-Received: by 2002:adf:dc91:0:b0:1f0:728c:8faf with SMTP id r17-20020adfdc91000000b001f0728c8fafmr9151784wrj.287.1646671643781; Mon, 07 Mar 2022 08:47:23 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:23 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 14/18] hw/intc/arm_gicv3: Fix missing spaces in error log messages Date: Mon, 7 Mar 2022 16:47:05 +0000 Message-Id: <20220307164709.2503250-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::432 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We forgot a space in some log messages, so the output ended up looking like gicv3_dist_write: invalid guest write at offset 0000000000008000size 8 with a missing space before "size". Add the missing spaces. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20220303202341.2232284-5-peter.maydell@linaro.org --- hw/intc/arm_gicv3_dist.c | 4 ++-- hw/intc/arm_gicv3_its.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c index 4164500ea96..28d913b2114 100644 --- a/hw/intc/arm_gicv3_dist.c +++ b/hw/intc/arm_gicv3_dist.c @@ -838,7 +838,7 @@ MemTxResult gicv3_dist_read(void *opaque, hwaddr offset, uint64_t *data, if (!r) { qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid guest read at offset " TARGET_FMT_plx - "size %u\n", __func__, offset, size); + " size %u\n", __func__, offset, size); trace_gicv3_dist_badread(offset, size, attrs.secure); /* The spec requires that reserved registers are RAZ/WI; * so use MEMTX_ERROR returns from leaf functions as a way to @@ -879,7 +879,7 @@ MemTxResult gicv3_dist_write(void *opaque, hwaddr offset, uint64_t data, if (!r) { qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid guest write at offset " TARGET_FMT_plx - "size %u\n", __func__, offset, size); + " size %u\n", __func__, offset, size); trace_gicv3_dist_badwrite(offset, data, size, attrs.secure); /* The spec requires that reserved registers are RAZ/WI; * so use MEMTX_ERROR returns from leaf functions as a way to diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c index 9f4df6a8cbb..b96b874afdf 100644 --- a/hw/intc/arm_gicv3_its.c +++ b/hw/intc/arm_gicv3_its.c @@ -1313,7 +1313,7 @@ static MemTxResult gicv3_its_read(void *opaque, hwaddr offset, uint64_t *data, if (!result) { qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid guest read at offset " TARGET_FMT_plx - "size %u\n", __func__, offset, size); + " size %u\n", __func__, offset, size); trace_gicv3_its_badread(offset, size); /* * The spec requires that reserved registers are RAZ/WI; @@ -1349,7 +1349,7 @@ static MemTxResult gicv3_its_write(void *opaque, hwaddr offset, uint64_t data, if (!result) { qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid guest write at offset " TARGET_FMT_plx - "size %u\n", __func__, offset, size); + " size %u\n", __func__, offset, size); trace_gicv3_its_badwrite(offset, data, size); /* * The spec requires that reserved registers are RAZ/WI; From patchwork Mon Mar 7 16:47:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548885 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1098437wrl; Mon, 7 Mar 2022 08:59:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJyoc8UigChE3MlZgTPTK/tUGLLHvdQMWHquf3sE8LTcp45LCWaW/b+9XqoEGpu+TLkUaHWF X-Received: by 2002:a25:3744:0:b0:629:2502:1bf with SMTP id e65-20020a253744000000b00629250201bfmr6649159yba.577.1646672399606; Mon, 07 Mar 2022 08:59:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646672399; cv=none; d=google.com; s=arc-20160816; b=VVcPqV6gM4XtZSpkBxZmJjL2HUjWLNnjIEVP15rHOvrQEBzX6xPIFPV+wGGfr2yYe3 s0hdrUoayvJds2+ZpuhyYQcR17bp/4rwy9uJm0V1H38mGYHBWZxpgeYR0P66yJLm+x2c cHpoBVyXtHy4zLSnP2+Cfv4Br0N+e5fv+qzR/doDCSZFsWYPqnDP4A4zcS0aiQXK/0d4 3VNxV9MfyIM09OuQ8EhbgJXJ6DDGVQ+6LKgEpHb35L3IF5wk3SnAhxrc1EE9URecnVIS kQTWQxKgQ51yVPoHWq2+HD32qklUIZX7T5iH04yqNTcAkq7YFwp7R3eD5QIfzNVjqwZF p/1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=MRh+1RqLLcfZLhVPGuXevsBv8v4iq4OG65QKu3dfbzw=; b=lr81JB11F05SYezubdQypMaQyTn9Hn2yK3/rUYdJhfNdf6aPuUejYrFHrUEGhXW103 8pXz1A0BwogrkpiSNwaa0+oTV+evYgsKrBXVKm9sddWgQds0QH69LSoCKb/dwjGaUSZA S2slbneLCdD13Kx8CIvkeknpYL2E0QvxWNLX5YhVHdxuQoinlJVTlbg933KZVuruknC1 7y5/QM3+HOUetIhE11trSoGiA703o9D11/q+wBwn/kPTQqn41NMloEqWaLBB2ZtAiuTg epD8IcSYUWTU5p4oDQvumfCjTacnNDsNZaImt6Wo1ZwSVFt6nTYyJbAsIZlqlScDdVNN DQ0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lA6lduca; 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 d17-20020a5b00d1000000b00628aa9d070dsi9676208ybp.666.2022.03.07.08.59.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:59:59 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lA6lduca; 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]:43170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGiF-0001vT-0v for patch@linaro.org; Mon, 07 Mar 2022 11:59:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGW7-0001v4-Bs for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:27 -0500 Received: from [2a00:1450:4864:20::335] (port=56172 helo=mail-wm1-x335.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGW5-0007lw-Tx for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:26 -0500 Received: by mail-wm1-x335.google.com with SMTP id i66so9555178wma.5 for ; Mon, 07 Mar 2022 08:47:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=MRh+1RqLLcfZLhVPGuXevsBv8v4iq4OG65QKu3dfbzw=; b=lA6lducashhhMtl8Li24OA+QT+sv8GjzsqDictcjJuoT4yf09sii/biSZtOMr2nIvE AqRHQAdEbZx3330YwXUpoA8d4eOEFTVLjoXT88izbo1cvm8hUsWxbb0AW6Au86O6RZyA rxfXgtstZMJD5X5f0wDHkqhhHXMIeghRXGXohlbVG7Eyi72ncvxRiGTOdkr+XPyGKRNN r+/lCQNvexIIpcr+ahedyxYukMlRUlmPz19OLYWFfqWqH+78vspfoKD2yLkHx8yNGyj4 +fILhI3NQeXYNUcKDiXQabc9mldvcPf6u+VTL5bCODg4KUXt3CnN7A4y/eeUHEvUw2wg AnEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MRh+1RqLLcfZLhVPGuXevsBv8v4iq4OG65QKu3dfbzw=; b=TUrCMW9dAUwbDvZ59vuN1niQRIWAe7YXojVmxDq3aMfqSxRNAyK/iAXlPwcs+rf3gW C6zGqJ+uwBVJvJDRLBw79Win74Uhe4JOVgXaNaH/uCRn8uXmjlOhQOwYn3i8/d38kvMq hfnlsHqANI/FSWP2/JhbwZFwfrpoJfs3nu3QFQTU81weFcxOxpSAuKrxfGWYzEvX/yfH XyG3ORazB71rlxTtpwu3p4AFpDYIZPv/VX5Wc/6jDcsfw1MWcDE+C9mMETl3jRvMWz/N P3kGRcYROlkQk1GCHZqDc/3syPmGMMeS33Run0BrmRfOzr5W9G2YgYAjIhqxwoZbM0NI 7wRQ== X-Gm-Message-State: AOAM532VLTmmdeFkuTfmj3bcRxMt1j3Y4vtx28doq5u/YE2ZmFjONZF+ aqJHje7ZcOHYs4Pw9BBqbhldOqi+AUtNpQ== X-Received: by 2002:a05:600c:19d4:b0:389:771e:3c4f with SMTP id u20-20020a05600c19d400b00389771e3c4fmr9799281wmq.23.1646671644689; Mon, 07 Mar 2022 08:47:24 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:24 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 15/18] hw/intc/arm_gicv3_cpuif: Fix register names in ICV_HPPIR read trace event Date: Mon, 7 Mar 2022 16:47:06 +0000 Message-Id: <20220307164709.2503250-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::335 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The trace_gicv3_icv_hppir_read trace event takes an integer value which it uses to form the register name, which should be either ICV_HPPIR0 or ICV_HPPIR1. We were passing in the 'grp' variable for this, but that is either GICV3_G0 or GICV3_G1NS, which happen to be 0 and 2, which meant that tracing for the ICV_HPPIR1 register was incorrectly printed as ICV_HPPIR2. Use the same approach we do for all the other similar trace events, and pass in 'ri->crm == 8 ? 0 : 1', deriving the index value directly from the ARMCPRegInfo struct. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20220303202341.2232284-6-peter.maydell@linaro.org --- hw/intc/arm_gicv3_cpuif.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c index d7e03d0cab8..1a3d440a54b 100644 --- a/hw/intc/arm_gicv3_cpuif.c +++ b/hw/intc/arm_gicv3_cpuif.c @@ -612,7 +612,8 @@ static uint64_t icv_hppir_read(CPUARMState *env, const ARMCPRegInfo *ri) } } - trace_gicv3_icv_hppir_read(grp, gicv3_redist_affid(cs), value); + trace_gicv3_icv_hppir_read(ri->crm == 8 ? 0 : 1, + gicv3_redist_affid(cs), value); return value; } From patchwork Mon Mar 7 16:47:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548884 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1098429wrl; Mon, 7 Mar 2022 08:59:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHx7n882u2cgEwcOTmYNu9r9YECxJk5LVogktYWC+BW4a6z9vJLUmnfREvLh1Lq/XZZUJo X-Received: by 2002:a25:bd41:0:b0:628:71a0:88af with SMTP id p1-20020a25bd41000000b0062871a088afmr8470598ybm.397.1646672398989; Mon, 07 Mar 2022 08:59:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646672398; cv=none; d=google.com; s=arc-20160816; b=PAu+JVuzlS2Fk/qGS1XZAnrM1Yn7efFjtL/YQTPuUbaaiuJTuYVwEf3xFOq3SSTjd5 Zew9eug8+oYv8zHW8477zc6PxKlKBWewvwMisufiLFNNeRAPTQOSPFzU/5eOw5gvNL1R PgMwHGx/YlfM9yzpxPqSM5wNVYnSfL+/li42zA6ZCrpXHc70ZUOMRYFJEF3MI1Te6D7j eP7fcK0ZE7PovLNxUSHwuy1MfczTct2+GNAFa1pt+w5RjuUdZg7AkCCtGP1XaW1oYy7d +vzKXBbBSZXaeE9GdpGwj/PINYnfPR/a5pkOiyItSP8ZyF7zvXySml/DYSBw7OmIAWL4 TD+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=U2DXG281yG+T8TcjY7hKoPvKUj4soEUbCsJuYEFv69Y=; b=nrPwNa4WUsz7acgFWzeDaCc/sC4H9i3PXuWVIjMD9zMOXZDYq9Ydlp+6j1ANWs6tsv RlGq1e9XFVOZVPeElckLKs0ayIX+J3h5O+sRJNoVD0w0p6RXRIlzIHnMVhMQFL+E4lV7 3xVPAdInE63cenevVJWW6Ldfptv7IHkWDV9vxCYpAaO4ozXHKOe40Jat6fLLqsEGiVMG fTsPJ1j7vEXikK6+C7RxOIJvMsVRRZpvuaTbV7Hx2pJUc/4UpEzpplAKLKhegn69Lthg BeBhO3HswsXqboYE087lVP30ptg9aTAUbPqf4A3nivieIKUrRn4ZTMqMW3Nhi5XSCkVx TV4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DXRtA6IK; 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 m130-20020a812688000000b002dbf43ed806si8981919ywm.408.2022.03.07.08.59.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:59:58 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DXRtA6IK; 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]:43124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGiE-0001to-Aw for patch@linaro.org; Mon, 07 Mar 2022 11:59:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGW8-000208-Pk for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:28 -0500 Received: from [2a00:1450:4864:20::430] (port=45966 helo=mail-wr1-x430.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGW6-0007mO-Rq for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:28 -0500 Received: by mail-wr1-x430.google.com with SMTP id p9so24271579wra.12 for ; Mon, 07 Mar 2022 08:47:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=U2DXG281yG+T8TcjY7hKoPvKUj4soEUbCsJuYEFv69Y=; b=DXRtA6IKLXX0B5QfLDpI41/XiSIvhTtaCneWcPBiJTHzBZNP2xKUUzQ6Hkic3NFKj6 fHTiC7VUfIJJ+yVntqxA+7+2ybrRDbiB0rcjX0kjMcAmSm5j1DsVdX0GjCdC9WJVjXIQ bT+DOjsduf4U0njNYtIYmeVO5jIMpAHdwA+Eb7mskW0Py5hH5yMuyuo1inNVNbGDtgGc vG+NvG/QeOQVrtTztD/0ho7wIL295xGzzt0kXDrqR8E482CXocZUKMYLi5eZNexm3RAV UWbjXGEm826IgZYvrMo5kijPCOC2lCGYvw+kka5osGA1xg6gR6n+mvcWSumGtYkZ8GKc oP5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U2DXG281yG+T8TcjY7hKoPvKUj4soEUbCsJuYEFv69Y=; b=mWE0/kjIbe532qspzzGwRygccEqvRiDelBrzmPkzW9DGMpMzx1qf5cu+t1qvr6tT09 ik2/b+dieIyVg+TY96uYJREhrbzLFoyDEv5r66FaptIAEjoMkVyc+Rmpt/fLq67JdRlF x7IVP9SW9qVSprVCSUTpfvwh2axClGGJrSPQMuLmAQu+CXzreUUZoyrWwQ3WGVBqBG4Y /E2zgtkWAKsCyuR4yl1ZBb/UZMEA5LNVvQpvUBJW9tUuKythYhMdvvuxTPtescJ8G8Rr BiBTpGfb8ye8rpzFG7Am+B4PZMxiF7wWIA2JoIq7LuQupzBC4KubBS7ddtmGuKB4soqZ m5BQ== X-Gm-Message-State: AOAM532qetXPw60EnNCRhFb7UxlCjhil+WN5jmKx/dayhjyCHxkjFPL7 dslKCWKRI1PbTeAD9oAot18/b++oR1Ejew== X-Received: by 2002:a5d:534a:0:b0:1f0:5c4b:cec8 with SMTP id t10-20020a5d534a000000b001f05c4bcec8mr9360646wrv.115.1646671645509; Mon, 07 Mar 2022 08:47:25 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:25 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 16/18] ui/cocoa: Use the standard about panel Date: Mon, 7 Mar 2022 16:47:07 +0000 Message-Id: <20220307164709.2503250-17-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::430 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Akihiko Odaki This provides standard look and feel for the about panel and reduces code. Signed-off-by: Akihiko Odaki Message-id: 20220227042241.1543-1-akihiko.odaki@gmail.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- ui/cocoa.m | 112 +++++++++++------------------------------------------ 1 file changed, 23 insertions(+), 89 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 8ab9ab5e84d..c88149852b0 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -83,7 +83,7 @@ static void cocoa_switch(DisplayChangeListener *dcl, static void cocoa_refresh(DisplayChangeListener *dcl); -static NSWindow *normalWindow, *about_window; +static NSWindow *normalWindow; static const DisplayChangeListenerOps dcl_ops = { .dpy_name = "cocoa", .dpy_gfx_update = cocoa_update, @@ -1140,7 +1140,6 @@ QemuCocoaView *cocoaView; - (BOOL)verifyQuit; - (void)openDocumentation:(NSString *)filename; - (IBAction) do_about_menu_item: (id) sender; -- (void)make_about_window; - (void)adjustSpeed:(id)sender; @end @@ -1186,8 +1185,6 @@ QemuCocoaView *cocoaView; [pauseLabel setFont: [NSFont fontWithName: @"Helvetica" size: 90]]; [pauseLabel setTextColor: [NSColor blackColor]]; [pauseLabel sizeToFit]; - - [self make_about_window]; } return self; } @@ -1471,92 +1468,29 @@ QemuCocoaView *cocoaView; /* The action method for the About menu item */ - (IBAction) do_about_menu_item: (id) sender { - [about_window makeKeyAndOrderFront: nil]; -} - -/* Create and display the about dialog */ -- (void)make_about_window -{ - /* Make the window */ - int x = 0, y = 0, about_width = 400, about_height = 200; - NSRect window_rect = NSMakeRect(x, y, about_width, about_height); - about_window = [[NSWindow alloc] initWithContentRect:window_rect - styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | - NSWindowStyleMaskMiniaturizable - backing:NSBackingStoreBuffered - defer:NO]; - [about_window setTitle: @"About"]; - [about_window setReleasedWhenClosed: NO]; - [about_window center]; - NSView *superView = [about_window contentView]; - - /* Create the dimensions of the picture */ - int picture_width = 80, picture_height = 80; - x = (about_width - picture_width)/2; - y = about_height - picture_height - 10; - NSRect picture_rect = NSMakeRect(x, y, picture_width, picture_height); - - /* Make the picture of QEMU */ - NSImageView *picture_view = [[NSImageView alloc] initWithFrame: - picture_rect]; - char *qemu_image_path_c = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/512x512/apps/qemu.png"); - NSString *qemu_image_path = [NSString stringWithUTF8String:qemu_image_path_c]; - g_free(qemu_image_path_c); - NSImage *qemu_image = [[NSImage alloc] initWithContentsOfFile:qemu_image_path]; - [picture_view setImage: qemu_image]; - [picture_view setImageScaling: NSImageScaleProportionallyUpOrDown]; - [superView addSubview: picture_view]; - - /* Make the name label */ - NSBundle *bundle = [NSBundle mainBundle]; - if (bundle) { - x = 0; - y = y - 25; - int name_width = about_width, name_height = 20; - NSRect name_rect = NSMakeRect(x, y, name_width, name_height); - NSTextField *name_label = [[NSTextField alloc] initWithFrame: name_rect]; - [name_label setEditable: NO]; - [name_label setBezeled: NO]; - [name_label setDrawsBackground: NO]; - [name_label setAlignment: NSTextAlignmentCenter]; - NSString *qemu_name = [[bundle executablePath] lastPathComponent]; - [name_label setStringValue: qemu_name]; - [superView addSubview: name_label]; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + char *icon_path_c = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/512x512/apps/qemu.png"); + NSString *icon_path = [NSString stringWithUTF8String:icon_path_c]; + g_free(icon_path_c); + NSImage *icon = [[NSImage alloc] initWithContentsOfFile:icon_path]; + NSString *version = @"QEMU emulator version " QEMU_FULL_VERSION; + NSString *copyright = @QEMU_COPYRIGHT; + NSDictionary *options; + if (icon) { + options = @{ + NSAboutPanelOptionApplicationIcon : icon, + NSAboutPanelOptionApplicationVersion : version, + @"Copyright" : copyright, + }; + [icon release]; + } else { + options = @{ + NSAboutPanelOptionApplicationVersion : version, + @"Copyright" : copyright, + }; } - - /* Set the version label's attributes */ - x = 0; - y = 50; - int version_width = about_width, version_height = 20; - NSRect version_rect = NSMakeRect(x, y, version_width, version_height); - NSTextField *version_label = [[NSTextField alloc] initWithFrame: - version_rect]; - [version_label setEditable: NO]; - [version_label setBezeled: NO]; - [version_label setAlignment: NSTextAlignmentCenter]; - [version_label setDrawsBackground: NO]; - - /* Create the version string*/ - NSString *version_string; - version_string = [[NSString alloc] initWithFormat: - @"QEMU emulator version %s", QEMU_FULL_VERSION]; - [version_label setStringValue: version_string]; - [superView addSubview: version_label]; - - /* Make copyright label */ - x = 0; - y = 35; - int copyright_width = about_width, copyright_height = 20; - NSRect copyright_rect = NSMakeRect(x, y, copyright_width, copyright_height); - NSTextField *copyright_label = [[NSTextField alloc] initWithFrame: - copyright_rect]; - [copyright_label setEditable: NO]; - [copyright_label setBezeled: NO]; - [copyright_label setDrawsBackground: NO]; - [copyright_label setAlignment: NSTextAlignmentCenter]; - [copyright_label setStringValue: [NSString stringWithFormat: @"%s", - QEMU_COPYRIGHT]]; - [superView addSubview: copyright_label]; + [NSApp orderFrontStandardAboutPanelWithOptions:options]; + [pool release]; } /* Used by the Speed menu items */ From patchwork Mon Mar 7 16:47:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548876 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1094055wrl; Mon, 7 Mar 2022 08:52:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7V8Ve6giD47d5Xp1JXnMIOZKeZYNd8Mdxyjzf+/n3zO0J2iJHE+xpa1G6Li9VWNp1Obbx X-Received: by 2002:a25:7804:0:b0:628:ec4c:989b with SMTP id t4-20020a257804000000b00628ec4c989bmr8320750ybc.428.1646671977992; Mon, 07 Mar 2022 08:52:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646671977; cv=none; d=google.com; s=arc-20160816; b=yjlJHnESAhf4lbDKx06C6+LukVSJpeb2XXyr0bq1xRWQB1yhr8P4UsjKdlfiUcI565 152Yk6dGLe62OaM/ipEY689rqbi1Kk0hZRiX7t8DUv8t3DUOubh3n17OFSLYe2VUa2Ns MEdOobuWiysFMZluO/8PVELsQ45y4oJQPFA2kC/TRo3WXXo8axBSaDcTH+NM5xGULoSc 2Rdg/P+6JV/WzT7NigSc79GkkB06W7VJ2fHseKlhfwU03ty6PLreUUausuRPV/MCbIcZ 2k5qLHTUcxkqNAJN2fnnM7H4NJ1c4Kw+nO+iyAa7LtIaqPbyZJMmxY+2zY8uAvwBbGrb HMpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=1uFtbkyoP6FALtVBSBQYa/7yZFXHFLiOSjVsvV63nhI=; b=0DuKpT3l+lh9xyrRaTD8kGrRfYWpAkvfW/H8o+abZnxvD3q4OS+eItB/qkdjXKjYjm XE7E+crfHvVx8IBljHVX6Ev5TkUb5OARX0/3BVSBiZTDlgBOJcRDaNjKkkj3Q5HcSJuD 62pWM29iaV9IYXXGNf6ZitBNHCPPuyjyiVwi3joAMOlDdoCxmxmuFsEIukbGS+pNm/wB rM2slP29llG/MT+1IwSoTmeZdLtM8zKRlkq1lBbHkYIwZhgRN3xGeDvFL2WPOR7i8gVb 2SIP2lWGNZNmxpO4ezwK23b50ziNDOijtG939upmEZCx2diF8RFQEev6o9Fq4P4Hy8kX rQiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fG5yZY+V; 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 f64-20020a251f43000000b00620f5f60543si8221013ybf.534.2022.03.07.08.52.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:52:57 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fG5yZY+V; 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]:49090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGbR-00045s-DZ for patch@linaro.org; Mon, 07 Mar 2022 11:52:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGWB-00023U-Hn for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:33 -0500 Received: from [2a00:1450:4864:20::32c] (port=41695 helo=mail-wm1-x32c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGW7-0007mY-JY for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:29 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 7-20020a05600c228700b00385fd860f49so8803967wmf.0 for ; Mon, 07 Mar 2022 08:47:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=1uFtbkyoP6FALtVBSBQYa/7yZFXHFLiOSjVsvV63nhI=; b=fG5yZY+VnwRpA397cIx7pnc5BjEX5gBPH9M2iuLHOZluX4mGR0/Me/JtSHBvNeUSiR rN5B8GxlLDCDIQ/HC7MzjR/6MnsulksdOUSo1p/0EbnlAf/b/BqaHhYnQ2jiYVGuaXap keRmdr0O+dDejiCj4itSxR4VWZvaM7AH54fNr/zTHbF2pA3PYKcDA29D+Eyl1D2Kq+mk KdjxOUugeLnKTaLtS5oPcmX2KPPzu1r0hpbXKguiEQw9YLlB8fVNXQ0yjQqP98K1XMbr cahkOgJ3mWdIxplZBHXv+p1401gZEBk7B1dcjQD9tAkndMv5SIdxd//3Yrtr8/94vjVh 8ZFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1uFtbkyoP6FALtVBSBQYa/7yZFXHFLiOSjVsvV63nhI=; b=HeG/K0l1i3w4CrR+7eR9FvY/5ZDM0ZWHWlXRxLCljDyLMznN6baVs6mAybqO3gyCJU +Od0nvO6TAYBdpXU79640VX/zx/K+A1HEZH8rB7FXIplkTzntfNu2z83X8bQ3XGvM3LS ue2cvTHRI+6YH0/3r7dp4eEVJkM96+/qZmmEwHY69x21PWM/K4WApBh+KJ6qmfr+CrzE KiVWGjZCjrhnSomvxdHsaw031qmYqizaDoLUV8MTNc9U0F8dAK0E2sJ0Pbi5gDiljxJE iIY8BvsiyS0iOhxEz6wLhPCFsVKcUXFUc0nPmwb3ouSn0KpmcGDA0tnO314o9VaWUVkc UzXw== X-Gm-Message-State: AOAM530b4Guhp5HyMprY2wf+g1iYsQJ+kF9mO1fREVSdJ9AvEh/myyGe xiP27njQ+/SUc/sXmtSa01WCl212oQ4WbA== X-Received: by 2002:a1c:ed0e:0:b0:380:fa8c:da99 with SMTP id l14-20020a1ced0e000000b00380fa8cda99mr9845859wmh.135.1646671646321; Mon, 07 Mar 2022 08:47:26 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:25 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 17/18] target/arm: Provide cpu property for controling FEAT_LPA2 Date: Mon, 7 Mar 2022 16:47:08 +0000 Message-Id: <20220307164709.2503250-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32c (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson There is a Linux kernel bug present until v5.12 that prevents booting with FEAT_LPA2 enabled. As a workaround for TCG, allow the feature to be disabled from -cpu max. Since this kernel bug is present in the Fedora 31 image that we test in avocado, disable lpa2 on the command-line. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/cpu.h | 5 ++++- target/arm/cpu.c | 6 ++++++ target/arm/cpu64.c | 24 ++++++++++++++++++++++++ tests/avocado/boot_linux.py | 2 ++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 24d9fff1705..4aa70ceca12 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -204,10 +204,12 @@ typedef struct { # define ARM_MAX_VQ 16 void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp); void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp); +void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp); #else # define ARM_MAX_VQ 1 static inline void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) { } static inline void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) { } +static inline void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp) { } #endif typedef struct ARMVectorReg { @@ -975,10 +977,11 @@ struct ARMCPU { /* * Intermediate values used during property parsing. - * Once finalized, the values should be read from ID_AA64ISAR1. + * Once finalized, the values should be read from ID_AA64*. */ bool prop_pauth; bool prop_pauth_impdef; + bool prop_lpa2; /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ uint32_t dcz_blocksize; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 7091684a16d..185d4e774d5 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1392,6 +1392,12 @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp) error_propagate(errp, local_err); return; } + + arm_cpu_lpa2_finalize(cpu, &local_err); + if (local_err != NULL) { + error_propagate(errp, local_err); + return; + } } if (kvm_enabled()) { diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 2fdc16bf182..eb44c05822c 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -688,6 +688,29 @@ void aarch64_add_pauth_properties(Object *obj) } } +static Property arm_cpu_lpa2_property = + DEFINE_PROP_BOOL("lpa2", ARMCPU, prop_lpa2, true); + +void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp) +{ + uint64_t t; + + /* + * We only install the property for tcg -cpu max; this is the + * only situation in which the cpu field can be true. + */ + if (!cpu->prop_lpa2) { + return; + } + + t = cpu->isar.id_aa64mmfr0; + t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN16, 2); /* 16k pages w/ LPA2 */ + t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN4, 1); /* 4k pages w/ LPA2 */ + t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN16_2, 3); /* 16k stage2 w/ LPA2 */ + t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN4_2, 3); /* 4k stage2 w/ LPA2 */ + cpu->isar.id_aa64mmfr0 = t; +} + static void aarch64_host_initfn(Object *obj) { #if defined(CONFIG_KVM) @@ -897,6 +920,7 @@ static void aarch64_max_initfn(Object *obj) aarch64_add_sve_properties(obj); object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq, cpu_max_set_sve_max_vq, NULL, NULL); + qdev_property_add_static(DEVICE(obj), &arm_cpu_lpa2_property); } static void aarch64_a64fx_initfn(Object *obj) diff --git a/tests/avocado/boot_linux.py b/tests/avocado/boot_linux.py index ab19146d1ee..ee584d2fdf2 100644 --- a/tests/avocado/boot_linux.py +++ b/tests/avocado/boot_linux.py @@ -79,6 +79,7 @@ def test_virt_tcg_gicv2(self): """ self.require_accelerator("tcg") self.vm.add_args("-accel", "tcg") + self.vm.add_args("-cpu", "max,lpa2=off") self.vm.add_args("-machine", "virt,gic-version=2") self.add_common_args() self.launch_and_wait(set_up_ssh_connection=False) @@ -91,6 +92,7 @@ def test_virt_tcg_gicv3(self): """ self.require_accelerator("tcg") self.vm.add_args("-accel", "tcg") + self.vm.add_args("-cpu", "max,lpa2=off") self.vm.add_args("-machine", "virt,gic-version=3") self.add_common_args() self.launch_and_wait(set_up_ssh_connection=False) From patchwork Mon Mar 7 16:47:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548879 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1095005wrl; Mon, 7 Mar 2022 08:54:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6E4Te3TSAGfRkktsdIWK4fd6oPbGTPqIntQN4x8LzzqH/mZwcra/81RS4JeXjillJ7iiI X-Received: by 2002:a81:8044:0:b0:2db:2d8b:154f with SMTP id q65-20020a818044000000b002db2d8b154fmr9770483ywf.191.1646672067193; Mon, 07 Mar 2022 08:54:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646672067; cv=none; d=google.com; s=arc-20160816; b=WJs7e6krAUJL5utrXMO942shbZ3q8yNrqVEOu2jMQr6+V7XdMF5SN+oxGNENhpkJ4p +DvOOlG76Zmlst0N16+hm/BmS5xlhNY+ZEv+AVordX3uhoI+nkWwK2zpTLOny3elZRwo SdJ2Gp0gBrvxoGdfSWSNXWLlUronCcRJP/QcwRfRh/Mvuxqf4WxBVw9wzzFDX+t5hExO NLoxA3rZb+wZOjMoZ4SrEGJEmBJjmhSzhFN7p5z8LwNew1TnvhJRzoLJ+anZEaW2wXMS XJlft/HARiGdjIMaIHidU+P82bWdL8ecrVNTuj9ktUvttBP51/3K9oh0HOyR2gqvHalj QH9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=rQyfB/hnr8PD3XNGQDMI+Pr8j6F6XBEv5eRGs9i8nt8=; b=fHbRd2MPpnmU4LV1SPLDhI2itN8GV8QjJh7kYymsjzMn096ZzJfWq+sNM75C/a+cmd ichnBpo7DeuBqr+2egoW0N7rMN/couXg0G90RdK0Pm8anM/2x60xw0sVKOUjXZIfcGaI B/2/dHbnWByFMJM6VQKwuKEeL9IOwUV8VgEsR/o7Mo8icHKPWausoKkR4JNICMB3zEGk Odhtg2zSa6cwz1hm+Jib9VNhC7rk2mlL+VLcbnIqdNXgJ9Bbg71/QAKLo66LOeT5llIK fC70258RNz7HohUJOIRaLkPVeiMLgIshOfp4yBIRj+HrtDPB5iDJL1IAr3ucrqU1vWUQ 002g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D10jSVS4; 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 i187-20020a816dc4000000b002dc8341e6dfsi4482898ywc.319.2022.03.07.08.54.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:54:27 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D10jSVS4; 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]:55520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGcs-0008J7-Kj for patch@linaro.org; Mon, 07 Mar 2022 11:54:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGWB-00023Y-KD for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:33 -0500 Received: from [2a00:1450:4864:20::42d] (port=43538 helo=mail-wr1-x42d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGW8-0007mo-BE for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:29 -0500 Received: by mail-wr1-x42d.google.com with SMTP id e24so11303259wrc.10 for ; Mon, 07 Mar 2022 08:47:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=rQyfB/hnr8PD3XNGQDMI+Pr8j6F6XBEv5eRGs9i8nt8=; b=D10jSVS475FnNaqQh2gJODWNdi1neVRNrKh53wfYyDUs+tiW/M7zdjfMwtlKeAZEKs VXrfpT63vUe30Bs6R6VJEKooRm8UI26e6wEKrWGTXtQUJfJrKkgXS0kVlcZYPd0m2myX tqNy7NM2OSPiP9D/Xfaqi7Ybe/b4eZ4XcskAQdYO0j+JlxvBRmL3KwI/IbuzsrLz0m2L YHXSn2jOazIt2iyzhxD9CdwmcyMsYYNkAhnosk4i8zC3DOq8XUCjOWmNCCpIoVS1fBjP K9gq9s9FQf++OYd4DalwzpuHciybry3EPTzF2F3t70+GuKJsnC9lJa/KcatG82l1HbjS /2Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rQyfB/hnr8PD3XNGQDMI+Pr8j6F6XBEv5eRGs9i8nt8=; b=4n4AnLhPdzGYt/k0TG5rwQtAUnW5cpwXLJit4O5Oy7wQte8+r7JxLLwYY7d8TInmeW oPARBXLW30vHhzGo2HgZs5kBq+PAMoFqzbRYiF3QNtirpsgdfRqeQ8rP9NM3uAevd5Nc HmE2ovWr5uzKZVbysj3W6X1PYXSU7KD1wxX8cU0kNMFflqTNNEJBikyyUR/XEy/nAoQE kpVrPNeBh/xA07+kj/m9rxLDMBHcObvAhmaoXmm2XKh5sLL9FuqyBqQuvCj76fr7SAoo k2pJRXNKzMomxAgOvjbAGSTNUeGaGYl8hmHouREMmXqt+BJ2h+MxGqnWKuAfA4cWmEm7 xO3A== X-Gm-Message-State: AOAM531RB07f2amgiPRuIR35K8Aq7++PIEudNHmhpvqoEQ12VaFipQPd gs2pOhIe/fBpe3QMvTQkyM/4V1xYVkpctw== X-Received: by 2002:a05:6000:1206:b0:1f1:e68d:a72b with SMTP id e6-20020a056000120600b001f1e68da72bmr6537274wrx.368.1646671647036; Mon, 07 Mar 2022 08:47:27 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:26 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 18/18] hw/arm/virt: Disable LPA2 for -machine virt-6.2 Date: Mon, 7 Mar 2022 16:47:09 +0000 Message-Id: <20220307164709.2503250-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42d (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson There is a Linux kernel bug present until v5.12 that prevents booting with FEAT_LPA2 enabled. As a workaround for TCG, disable this feature for machine versions prior to 7.0. Cc: Daniel P. Berrangé Signed-off-by: Richard Henderson Signed-off-by: Peter Maydell Reviewed-by: Peter Maydell --- include/hw/arm/virt.h | 1 + hw/arm/virt.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index c1ea17d0def..7e76ee26198 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -132,6 +132,7 @@ struct VirtMachineClass { bool no_secure_gpio; /* Machines < 6.2 have no support for describing cpu topology to guest */ bool no_cpu_topology; + bool no_tcg_lpa2; }; struct VirtMachineState { diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 46bf7ceddf3..46a42502bc5 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2102,6 +2102,10 @@ static void machvirt_init(MachineState *machine) object_property_set_bool(cpuobj, "pmu", false, NULL); } + if (vmc->no_tcg_lpa2 && object_property_find(cpuobj, "lpa2")) { + object_property_set_bool(cpuobj, "lpa2", false, NULL); + } + if (object_property_find(cpuobj, "reset-cbar")) { object_property_set_int(cpuobj, "reset-cbar", vms->memmap[VIRT_CPUPERIPHS].base, @@ -3020,8 +3024,11 @@ DEFINE_VIRT_MACHINE_AS_LATEST(7, 0) static void virt_machine_6_2_options(MachineClass *mc) { + VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); + virt_machine_7_0_options(mc); compat_props_add(mc->compat_props, hw_compat_6_2, hw_compat_6_2_len); + vmc->no_tcg_lpa2 = true; } DEFINE_VIRT_MACHINE(6, 2)