From nobody Tue Nov 26 17:27:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705796563; cv=none; d=zohomail.com; s=zohoarc; b=kCVQA9qjkg8jToUpO3qEirWLTQEK9bld3OmWadozjPU75TrhDbDI1FaJkti8Vw6Sp1W7jJBF3CVHc67zOObuJU+SZCkVJJc8YNuEKG3G7FC8dKLRFwAtwk33yae9y+ktenYX/1qwYmlw6AilSgSVPUNXzMP11fQopMeh3rgHNLw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705796563; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8KxhZwbZAcm1asBjHob1LgeGTJkXdHPPGTQpwmtvThw=; b=HcbtirrZsLJUOdSo+WJjaJrrNYddhshKXvsDobL35Ejh0rNoFIlu9fzsoKgyJjkcTEkeXx3FD3rf38RbQe+mrjjT77ZFVG2dkhJWSN29lr6asRQ3OsuYCh+TvGmX6MNAllWVRczHFOIhw/mpVa5aNLSQ7m3+tuuDP+q3N5mE3nU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705796563955747.4493164360758; Sat, 20 Jan 2024 16:22:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rRLaA-0002VK-7D; Sat, 20 Jan 2024 19:21:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rRLa7-0002UO-Sm for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:00 -0500 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rRLa6-0007Mr-3U for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:20:59 -0500 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2906dffd8ddso553458a91.3 for ; Sat, 20 Jan 2024 16:20:57 -0800 (PST) Received: from stoup.net ([2001:8004:5170:1e39:1361:3840:4873:7990]) by smtp.gmail.com with ESMTPSA id j4-20020a17090276c400b001d5af7fbda0sm5023546plt.122.2024.01.20.16.20.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 16:20:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705796456; x=1706401256; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8KxhZwbZAcm1asBjHob1LgeGTJkXdHPPGTQpwmtvThw=; b=luDG2Cf9OECkgoT3f/VB0mWaYPwAh2Y+OYkGJ/3eVyX9u5ZwE6OHVG6bDvqBznyL9/ 4sbfcBagNHPbY1ICyoj86Gh1/ic+vMs+NC8cw++tK7/uVvWRKwhk96pcIvkopryK4/HP H74IagG9x0KNn/KvImZMsTNqPU6pGzyXvD/KZbHQvNkGiLHMEy+RuHPRdBA1IHtItoGo gqIl2UJYSOCDVFzKDdlslTZBbjyZIyYVAoH09+1RMIHKfhSMI868qM2EC3EBtG/kGxUX nhQH37YwtGP5sMRSFnAXR6CspJMmfH9wgGSD2pYVM0kAZvQm3x+QPaFT0fewTUq6YrUA /V2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705796456; x=1706401256; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8KxhZwbZAcm1asBjHob1LgeGTJkXdHPPGTQpwmtvThw=; b=hw9nybuIBXs6oJwlaTeD2zfsUZcxjAulfflCNO1X5u7B6upQxlDRNCF8fT4vDFaKHh /7J+KlouwRwrOClB3ibABeFA2LFE1KBh+MUbe1xBizXR7Bt689ewuFJ5a6NaKpzRej8D CkdN88l2eBNYe3M0v2utYdzjDvzc0lG30WzyRIkKI9tRcLcxfXey9IEuUSiiUki/wIP0 gQhAwoSCTTiev8ysM2VLWedIPmt5jzP8J7fqtjfcWasB5ahKPbb+KGbSnrrp8k0sA1Ij 4/CntH+XJ8Z5tGLeQyOwfwdSRvDD0o8xc773uGrWC/Gixidh3VLyQtMoHEUtiNx0jarR hU4Q== X-Gm-Message-State: AOJu0YyoziZrD0XJaT0Y6n2NwlIHHrlasTqbNywexmlEkCAxMcjgcEMJ IReU/HiH7Wu5JjFxzp+x5q3RDONHMGp+sk0HpR9bw0f+ZAHvNswcHMQRu5rUo4FBPDGRfduCrXk 6GLo= X-Google-Smtp-Source: AGHT+IHHIaDEQeNXpAuLF9wYfwYVW2+qTTlzU/3VNlEqA8drj2Za+NBQTPSYDspL1DaClHCJnXASiQ== X-Received: by 2002:a17:902:b78a:b0:1d6:fbab:d40b with SMTP id e10-20020a170902b78a00b001d6fbabd40bmr2467590pls.85.1705796456442; Sat, 20 Jan 2024 16:20:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Samuel Tardieu , Peter Maydell Subject: [PULL 1/8] tcg: Remove unreachable code Date: Sun, 21 Jan 2024 11:20:40 +1100 Message-Id: <20240121002047.89234-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121002047.89234-1-richard.henderson@linaro.org> References: <20240121002047.89234-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705796565846100005 Content-Type: text/plain; charset="utf-8" From: Samuel Tardieu The `fail_rx`/`fail` block is only entered while `buf_rx` is equal to its initial value `MAP_FAILED`. The `munmap(buf_rx, size);` was never executed. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2030 Signed-off-by: Samuel Tardieu Reviewed-by: Peter Maydell Message-Id: <20231219182212.455952-2-sam@rfc1149.net> Signed-off-by: Richard Henderson --- tcg/region.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tcg/region.c b/tcg/region.c index 86692455c0..467e51cf6f 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -597,9 +597,7 @@ static int alloc_code_gen_buffer_splitwx_memfd(size_t s= ize, Error **errp) fail_rx: error_setg_errno(errp, errno, "failed to map shared memory for execute= "); fail: - if (buf_rx !=3D MAP_FAILED) { - munmap(buf_rx, size); - } + /* buf_rx is always equal to MAP_FAILED here and does not require clea= nup */ if (buf_rw) { munmap(buf_rw, size); } --=20 2.34.1 From nobody Tue Nov 26 17:27:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705796539; cv=none; d=zohomail.com; s=zohoarc; b=msI6wAWlHDPdUEUDNL1AKpxOpecXuIHyuGDrMUmyqlkjX5eg9Jyu0jui6b46MNYmUQdelFmV04W21JAR3B2ii+dHFOHr18Jwl7AXZ4YuRbii1n7kJ3V0vtWYpR4ruJND0IoUjLrell1Kfv55FbTCttDjCy66hA0Gn///xhhF1tI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705796539; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0EKsORzhcd/voY/5GCXD+0ZH5a0YI/B7BiYyHrdge+w=; b=WwEcY6RwonlDoUlJ+F6LZkswqgssUPz5N/QgLEF7dZEcgfF7JbjcsLdwbXPKikFZ1yPWPGodaV+yilEjerVjtViDJ8K+62Fyn0efkd/0/1uwGUOsJ+35UtFuq/61KNVtexIKXj1d0q2Rl4VqcitX/jZYbvpjQSjAjy7hRnQ/eHY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705796539470247.4551862143402; Sat, 20 Jan 2024 16:22:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rRLaB-0002Vl-E7; Sat, 20 Jan 2024 19:21:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rRLaA-0002VV-8l for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:02 -0500 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rRLa8-0007NJ-Ll for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:02 -0500 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2907a17fa34so321870a91.1 for ; Sat, 20 Jan 2024 16:21:00 -0800 (PST) Received: from stoup.net ([2001:8004:5170:1e39:1361:3840:4873:7990]) by smtp.gmail.com with ESMTPSA id j4-20020a17090276c400b001d5af7fbda0sm5023546plt.122.2024.01.20.16.20.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 16:20:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705796459; x=1706401259; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0EKsORzhcd/voY/5GCXD+0ZH5a0YI/B7BiYyHrdge+w=; b=nqalHe+rh82CZBZ1Z/S67KA8JIcjQHp7CLdyJwb1G8HPF6tCcI1DF+Hnv2uyRe8gNu q7ggjET41HzG9uutAQKUzdacn9s9CMBTOf4NBXdbe5mv8m5uSC0m+u9JVBDf8WWkdqa+ zYV6+fFJoQancPRxF50YJjWHBjD+4ev1Zk5KuhS0xxTJsYbn/VBpfV53DTYOHoltzBBK vJbVmBR3f8UOHj8vujYo6YbL77yG7mldXfCMa8JDDMzmcfw5VIf77KTAfr6Vcf/XZtR8 7Te/gFg+bTdjp5i9tcti2qgrdVT5RblfsfMvdo/OqoXsRWHQwPaDKxqhxNOshaGgvHS9 Gp5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705796459; x=1706401259; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0EKsORzhcd/voY/5GCXD+0ZH5a0YI/B7BiYyHrdge+w=; b=wriyRuX0FdbwcvFLiL4zV1IYrFVys44JzojlCpzcg2F2jLy6vdct4pYGjlpJfsrqzu btfh/udgvYsj/xRyV7A6PcCAh3OZXPJ1Oqe9BuTnQH2ZgPzk7f/EIqdhNHqpPzsy853C 6Cy/PeosrPLN+nlC8VxtZmVwI2bqaMxjf++Q2847Fi+6ImRHjEpz20JtuAPkTO7yOrTW 3n2PQzrcXe8xoqVVwVJ576/Dv14daLLYKUwJuHAtn3MGV/iq58DcKdooKIBK4QokcmfG wQhEpHnsUIg+8/yMocYfNqoH9kGLphPv/VkrOLGrgHOff5WDOpQfZtfoYbouQ6Fm5x0s jVog== X-Gm-Message-State: AOJu0Yw7GapxQbnG9IL5bVA8tXMWQu+sbCVkZA9TitwNv0yUK77EOxvG uqY3HjA2zz9aFakXvzPiJ6dUVgC8dbEPVfebyDmRUMsWU51IGo4oYi3BK6xBmLG56qHfxHDlwGY CwKI= X-Google-Smtp-Source: AGHT+IGEiQ4B14hNvlpyw9JSKxin1v4woTMUnTOj3vv4/El2Y/RUz+bQsELjUyQ4YC+2WvPborCYaw== X-Received: by 2002:a17:902:7601:b0:1d7:4821:b567 with SMTP id k1-20020a170902760100b001d74821b567mr151074pll.139.1705796459447; Sat, 20 Jan 2024 16:20:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Samuel Tardieu , Peter Maydell Subject: [PULL 2/8] tcg: Make the cleanup-on-error path unique Date: Sun, 21 Jan 2024 11:20:41 +1100 Message-Id: <20240121002047.89234-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121002047.89234-1-richard.henderson@linaro.org> References: <20240121002047.89234-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705796541846100005 Content-Type: text/plain; charset="utf-8" From: Samuel Tardieu By calling `error_setg_errno()` before jumping to the cleanup-on-error path at the `fail` label, the cleanup path is clearer. Signed-off-by: Samuel Tardieu Reviewed-by: Peter Maydell Message-Id: <20231219182212.455952-3-sam@rfc1149.net> Signed-off-by: Richard Henderson --- tcg/region.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tcg/region.c b/tcg/region.c index 467e51cf6f..478ec051c4 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -584,7 +584,9 @@ static int alloc_code_gen_buffer_splitwx_memfd(size_t s= ize, Error **errp) =20 buf_rx =3D mmap(NULL, size, host_prot_read_exec(), MAP_SHARED, fd, 0); if (buf_rx =3D=3D MAP_FAILED) { - goto fail_rx; + error_setg_errno(errp, errno, + "failed to map shared memory for execute"); + goto fail; } =20 close(fd); @@ -594,8 +596,6 @@ static int alloc_code_gen_buffer_splitwx_memfd(size_t s= ize, Error **errp) =20 return PROT_READ | PROT_WRITE; =20 - fail_rx: - error_setg_errno(errp, errno, "failed to map shared memory for execute= "); fail: /* buf_rx is always equal to MAP_FAILED here and does not require clea= nup */ if (buf_rw) { --=20 2.34.1 From nobody Tue Nov 26 17:27:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705796542; cv=none; d=zohomail.com; s=zohoarc; b=TbZwHN66Q4GFY+iue9fK/Zk3PwXRP+jgS2nBLvw4xeD/lASYfgHUgs+wSkT3BHyaSpvu+EQgQsQWnJU4Ft5EaMOUX9qkpCogM7HRdc0EazWL8QXem//OJKUWy98+SVlQN1LqbzfHtfJCJ2jj2IzAPV0HW52SjYmW3bzw+uiX+sw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705796542; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CJwQ5ZzhzO00+g0UGwDiX0qf7mCAm8ExrbTS/sZFCpk=; b=g3isxCGjLWSq+8dmNjmT5BqTZfPkTcB7XCH6gsfUhQPye5l0mEn45bfGzdPGGKlWacP9zxeBpNJhHjSIvpz0OAI+erYGTOf3YMSF8hnO5S+6aHF1yt4Wn7fD7oECLMAWUMS+pSzlCTgzcgzXZNFG2R/lXg3k9PNJTXa0WAmyOD4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705796542854653.7367363305736; Sat, 20 Jan 2024 16:22:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rRLaG-0002WZ-6H; Sat, 20 Jan 2024 19:21:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rRLaE-0002W3-23 for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:06 -0500 Received: from mail-il1-x133.google.com ([2607:f8b0:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rRLaB-0007P5-F1 for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:04 -0500 Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-36201722a7cso2146745ab.2 for ; Sat, 20 Jan 2024 16:21:03 -0800 (PST) Received: from stoup.net ([2001:8004:5170:1e39:1361:3840:4873:7990]) by smtp.gmail.com with ESMTPSA id j4-20020a17090276c400b001d5af7fbda0sm5023546plt.122.2024.01.20.16.20.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 16:21:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705796462; x=1706401262; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CJwQ5ZzhzO00+g0UGwDiX0qf7mCAm8ExrbTS/sZFCpk=; b=EyhLAyNPKBwEvxm+EbslBqz2LEavZEf8npnFeBgBmiSZMDo/KxRSJ5wH+QbF3WCaoW +64tw6cz6We529M0BB6eh8dCona0SFRAzClv217WkFF3LOKILtCf+X7wiCdKxJVqjIw0 NUFVEqljjPAxzb0yOAcTt96Dzjbr6OL8BRg/+3DMq7S5T5ZNC19HJVS8ptiZc6KMxjWK 4oE6hGWLlI5EsDJ9iYtk0tKj9l2DK1o0i7B1drrIf3vfve86/FWSqu0aqTB1j+JKMj1H B0tUQpfmHNVd8whrsaE3HyUkbKziYkczEOiioQ3q2WCcltpGGn6IV1QwEDVUxTQsz/ak wXyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705796462; x=1706401262; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CJwQ5ZzhzO00+g0UGwDiX0qf7mCAm8ExrbTS/sZFCpk=; b=th6LYheDEQgWRjdQPS9jbQ4CPqd990axatt+k4N77BiPsdvLwIt+8rf6aLjXZ2yKQu GquaYYevQMCIE/cdlm5mBfNs6I0KiGOGYaL4XAH35dr27M/4QVIbWUdZlbYQ/8CMaf7o wpwSrwZ4dgkn/7xOlLfLNM099dE61mt4wMverMR1x4O0WL52he9OTAZlQU5XMLF//tHF eWA0C0uTSRjy/x7ydrYplg/wIJRre6utHTs0giHNVdgOOgPgYoGdVzYCF6JlnYO9uH47 N8NfSE+4B3QeyUUT36df/l7hfwEsuUeLdJef1AfjFxpvPXeLV7fSOYizfsj6EAD0680v Vqkw== X-Gm-Message-State: AOJu0YxxjBeopel6rGDDURcRSdxXK//UZKdgi5jS77LPPWgyq7U5oKUv 8AT5L7UTItokZIwO2CKI5VvexHz7Z4xQrJlQjbVLhv35M0yh/4yaYWWlYfdzcGpTr0ZKKaVtxE6 mfFM= X-Google-Smtp-Source: AGHT+IEEMcnSBg73OcDCeUR0w3ZirKD8muFeo8AtczFP2EgyWWDVuF4q9pkrcYzwuI4dNqEIJ1NWig== X-Received: by 2002:a92:c6c3:0:b0:361:9665:da9d with SMTP id v3-20020a92c6c3000000b003619665da9dmr3520252ilm.9.1705796462205; Sat, 20 Jan 2024 16:21:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Robbin Ehn , Palmer Dabbelt Subject: [PULL 3/8] linux-user: Fixed cpu restore with pc 0 on SIGBUS Date: Sun, 21 Jan 2024 11:20:42 +1100 Message-Id: <20240121002047.89234-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121002047.89234-1-richard.henderson@linaro.org> References: <20240121002047.89234-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::133; envelope-from=richard.henderson@linaro.org; helo=mail-il1-x133.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705796543639100011 Content-Type: text/plain; charset="utf-8" From: Robbin Ehn Commit f4e1168198 (linux-user: Split out host_sig{segv,bus}_handler) introduced a bug, when returning from host_sigbus_handler the PC is never set. Thus cpu_loop_exit_restore is called with a zero PC and we immediate get a SIGSEGV. Signed-off-by: Robbin Ehn Fixes: f4e1168198 ("linux-user: Split out host_sig{segv,bus}_handler") Reviewed-by: Palmer Dabbelt Message-Id: <33f27425878fb529b9e39ef22c303f6e0d90525f.camel@rivosinc.com> Signed-off-by: Richard Henderson --- linux-user/signal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index b35d1e512f..c9527adfa3 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -925,7 +925,7 @@ static void host_sigsegv_handler(CPUState *cpu, siginfo= _t *info, cpu_loop_exit_sigsegv(cpu, guest_addr, access_type, maperr, pc); } =20 -static void host_sigbus_handler(CPUState *cpu, siginfo_t *info, +static uintptr_t host_sigbus_handler(CPUState *cpu, siginfo_t *info, host_sigcontext *uc) { uintptr_t pc =3D host_signal_pc(uc); @@ -947,6 +947,7 @@ static void host_sigbus_handler(CPUState *cpu, siginfo_= t *info, sigprocmask(SIG_SETMASK, host_signal_mask(uc), NULL); cpu_loop_exit_sigbus(cpu, guest_addr, access_type, pc); } + return pc; } =20 static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) @@ -974,7 +975,7 @@ static void host_signal_handler(int host_sig, siginfo_t= *info, void *puc) host_sigsegv_handler(cpu, info, uc); return; case SIGBUS: - host_sigbus_handler(cpu, info, uc); + pc =3D host_sigbus_handler(cpu, info, uc); sync_sig =3D true; break; case SIGILL: --=20 2.34.1 From nobody Tue Nov 26 17:27:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705796544; cv=none; d=zohomail.com; s=zohoarc; b=knA/MBOSrNIwjDW90tPP8g+UyAR64dNLtNQKEHCb2ThRx2tY7qur6Ki5vvXr5QzoDDT92lPp9Q5ntLHebkulZ+WZhZKKIkEPLHKV5czWXFF1m/ZdgpRSXEIOTbgvHqOvAtV3FyUc+P8ZHBbkTAfXW0kkiNM9nrNAxuJ+wuvMx1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705796544; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lU9aH7ZY0n7uAdgAxQsFLjxICAM1xx6kGJSgqsKuTsU=; b=ML83yzaHasAf4mPOZJze16/MDz65B4Gh3XJNu+9ukz3RrFKTzHQUJZsUeAInVgtcMA0sFuJy0XJazaxVItWl5i86OZMi34EFwPtEWvRU1xY8YRd79SxbVvYKPcYvt04MuyktbqF+Iphggo3XSJw87eZRLnmCmrFPDKJ4QRWZEP4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705796544475553.1177576320447; Sat, 20 Jan 2024 16:22:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rRLaJ-0002XR-4W; Sat, 20 Jan 2024 19:21:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rRLaH-0002X0-6S for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:09 -0500 Received: from mail-il1-x132.google.com ([2607:f8b0:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rRLaF-0007Pj-8P for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:08 -0500 Received: by mail-il1-x132.google.com with SMTP id e9e14a558f8ab-361ae51a4d9so5617515ab.1 for ; Sat, 20 Jan 2024 16:21:06 -0800 (PST) Received: from stoup.net ([2001:8004:5170:1e39:1361:3840:4873:7990]) by smtp.gmail.com with ESMTPSA id j4-20020a17090276c400b001d5af7fbda0sm5023546plt.122.2024.01.20.16.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 16:21:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705796465; x=1706401265; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lU9aH7ZY0n7uAdgAxQsFLjxICAM1xx6kGJSgqsKuTsU=; b=Ju3VHi3YYiapsoWoAe9WLa2G13rKjQjHhckC23XlODTyXeG7CsqBgBvxOIy9tA3cIp ec45kYs0+aDEwpLKe7qcuQXWsMWPR+tAMVlwsgbYRSZ5UzejQarvE7VdvxE8r9hkQ2d5 I9iKfS04DskQUO1Gp/7EStO3G+7eo3Z+rzyadSVxupS9PDx7TdeYX9IrekC9Pm2bSdXc 7oBb+LfX5HRafrEtQDS2UoYV+FtWhpAWv3qCw7QS07sWbDRNeEnZlhiCMfSDipvEZ1Mq XGeCo61rfzTCJM6jJTPvZWux7JLtFTHCTctnCchNgBW2JS+V+KeL5ai4/YRQHhVpvo2z pxgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705796465; x=1706401265; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lU9aH7ZY0n7uAdgAxQsFLjxICAM1xx6kGJSgqsKuTsU=; b=S6ewddz4Hn7Wyd+NaCw2pa4GBIH9bT0LMr73nwVCkPM2F4JW2MJCCAnfC2TcKJ64+l CB54NPVyi93j96v2oj63x6nkN/aKvCI5u3StlrjDLRjbmz7L+kBf/qSdE00CTRSlsKWy XUojmyq6MHhoZ8LU7bu39IC9gYCyewyYocLdlGZZAIGhL0FoXY+QIj7Je657l5qqKc6G woPnzVdjkgIv6JewVge+Od/k71+GedfZ4eDyoxWhBRCSadjPZdZclGDbL+7t2aa8V0RU 8XlmevUJQwJw3eWObqRpf9NNGLlt/Bfq/RfKsWndeRbQT7p5trsZL3Vn0Ht74HJq7r4Z 1aLw== X-Gm-Message-State: AOJu0YyqjsjWvBgGpsmfAf/qKE8IX3UoYetc9+Uz3HZ2IPEgPDxFCoJX Woob8itbEHHfBuj8Pv291HxMbieQyPF+ZTdwTmbcdEWAhRLOJu+pRltnivY0L9MO2YnrQGH6Bxe DOM0= X-Google-Smtp-Source: AGHT+IFnCGNiLSxIKQIjulzY/IsK9QYvi2eMWQBcJd4wT71onI2IcJ88OoIlbNAcPevaWdYrzTfH8Q== X-Received: by 2002:a92:c110:0:b0:361:a867:5881 with SMTP id p16-20020a92c110000000b00361a8675881mr3558335ile.14.1705796465565; Sat, 20 Jan 2024 16:21:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Michael Tokarev , Thomas Huth Subject: [PULL 4/8] tcg/s390x: Fix encoding of VRIc, VRSa, VRSc insns Date: Sun, 21 Jan 2024 11:20:43 +1100 Message-Id: <20240121002047.89234-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121002047.89234-1-richard.henderson@linaro.org> References: <20240121002047.89234-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::132; envelope-from=richard.henderson@linaro.org; helo=mail-il1-x132.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705796545704100015 Content-Type: text/plain; charset="utf-8" While the format names the second vector register 'v3', it is still in the second position (bits 12-15) and the argument to RXB must match. Example error: - e7 00 00 10 2a 33 verllf %v16,%v0,16 + e7 00 00 10 2c 33 verllf %v16,%v16,16 Cc: qemu-stable@nongnu.org Reported-by: Michael Tokarev Fixes: 22cb37b4172 ("tcg/s390x: Implement vector shift operations") Fixes: 79cada8693d ("tcg/s390x: Implement tcg_out_dup*_vec") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2054 Reviewed-by: Thomas Huth Tested-by: Michael Tokarev Message-Id: <20240117213646.159697-2-richard.henderson@linaro.org> Signed-off-by: Richard Henderson --- tcg/s390x/tcg-target.c.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index fbee43d3b0..7f6b84aa2c 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -683,7 +683,7 @@ static void tcg_out_insn_VRIc(TCGContext *s, S390Opcode= op, tcg_debug_assert(is_vector_reg(v3)); tcg_out16(s, (op & 0xff00) | ((v1 & 0xf) << 4) | (v3 & 0xf)); tcg_out16(s, i2); - tcg_out16(s, (op & 0x00ff) | RXB(v1, 0, v3, 0) | (m4 << 12)); + tcg_out16(s, (op & 0x00ff) | RXB(v1, v3, 0, 0) | (m4 << 12)); } =20 static void tcg_out_insn_VRRa(TCGContext *s, S390Opcode op, @@ -738,7 +738,7 @@ static void tcg_out_insn_VRSa(TCGContext *s, S390Opcode= op, TCGReg v1, tcg_debug_assert(is_vector_reg(v3)); tcg_out16(s, (op & 0xff00) | ((v1 & 0xf) << 4) | (v3 & 0xf)); tcg_out16(s, b2 << 12 | d2); - tcg_out16(s, (op & 0x00ff) | RXB(v1, 0, v3, 0) | (m4 << 12)); + tcg_out16(s, (op & 0x00ff) | RXB(v1, v3, 0, 0) | (m4 << 12)); } =20 static void tcg_out_insn_VRSb(TCGContext *s, S390Opcode op, TCGReg v1, @@ -762,7 +762,7 @@ static void tcg_out_insn_VRSc(TCGContext *s, S390Opcode= op, TCGReg r1, tcg_debug_assert(is_vector_reg(v3)); tcg_out16(s, (op & 0xff00) | (r1 << 4) | (v3 & 0xf)); tcg_out16(s, b2 << 12 | d2); - tcg_out16(s, (op & 0x00ff) | RXB(0, 0, v3, 0) | (m4 << 12)); + tcg_out16(s, (op & 0x00ff) | RXB(0, v3, 0, 0) | (m4 << 12)); } =20 static void tcg_out_insn_VRX(TCGContext *s, S390Opcode op, TCGReg v1, --=20 2.34.1 From nobody Tue Nov 26 17:27:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705796549; cv=none; d=zohomail.com; s=zohoarc; b=njYu1JtN/WuiB6aKnB3N+tLqtogz3OorWPjq6dWTAmQNoWsMZ26ZtQeYR+kBAaBcPWD++eXJaouNAvSA9JoK6fXXP1KLfSOtrglxPfYM5ZjBjpNHP/t6jG7qQsGSqB/ICPPSRDUsKDDafHnatJjhv1zq33NM285lRa4nVVzYInM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705796549; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hlgMoCbNlbK2kYnDr6aEn76H+rXWsz2BjY76x4m7kmQ=; b=hubI6m+5OlXxykLmsaCMjNzZhw1i+r26KTPh1A/eujn87nCEogOjtTyCzCHlcIVJD/UbYxn++IAHMLlqRVSE6dffNbdn2EUgKUEloBk9aFUj4kZUdxm5Y4WhzGgrC4s+l7DB+pS2V5MF6Sn/izsHGCqxNanadQD4PwprqDZf4+I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705796549870754.4778822598297; Sat, 20 Jan 2024 16:22:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rRLaN-0002Xv-8R; Sat, 20 Jan 2024 19:21:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rRLaL-0002Xm-9e for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:13 -0500 Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rRLaH-0007QJ-Ti for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:13 -0500 Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-7bf617dcedaso92352739f.0 for ; Sat, 20 Jan 2024 16:21:09 -0800 (PST) Received: from stoup.net ([2001:8004:5170:1e39:1361:3840:4873:7990]) by smtp.gmail.com with ESMTPSA id j4-20020a17090276c400b001d5af7fbda0sm5023546plt.122.2024.01.20.16.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 16:21:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705796469; x=1706401269; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hlgMoCbNlbK2kYnDr6aEn76H+rXWsz2BjY76x4m7kmQ=; b=dxpicevosLthobJj7mqrQNSfJH0Qitxn8m1/JJNkdjAtoyaceeh5kWgVfEOQkuXxVQ U+QORA90rlP7+5wfz4o9w4k2mzRfAK78EDrdqnFi61mYlMogwwioSZIFzBEc3wHCCCkS hGKheBTdY858gu/kKamDPB4kvttxn8SqfU+RPQnqPllOxJkqyv4EAubNiwFFTsW/IW4Q rBAL04ygKcuqt0wndvycnzSGwZOJvMSrPPXnq4CbhteyEr6XNsA/bhL8ZuxyXVHV5hfS 1U0hkNRj/8nHXJ9ejwyOxZtm5R5lKywQHphpQCmzfCFmvfMOp/9QsBpnCqqqLWpr4cFJ EeVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705796469; x=1706401269; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hlgMoCbNlbK2kYnDr6aEn76H+rXWsz2BjY76x4m7kmQ=; b=BKwv/nhj6sqe+CANlA1W7/oA25IjFfb3omyKs+0DoY7IHiUDHOxgE8kqqm42kdH0q0 EVtQHOUM3P+cRAFhG7lmp0ckOFZLXTrMEXW2lYRViYGlL5uTFltepLECUuTtehrDsRx4 sBilkrVA/UyGBo363zCa/P44NLFWAARECuiLpaLHLkDtcKqod+saLEf6hejtbsatkaW1 UsNAdOHQbPg+kB0sOSsA7Z0rtrvHsKZdrsdkH2YSbSt/CPQOugGkxW51VRX5jJQ17Upe iR3qN8rd1Ba0oEGFqzN9V8P3QpEiT+4CTg8OLpchJInZ7Dt+zSxYMGx0u+1YkibWewPS DzfA== X-Gm-Message-State: AOJu0YyiCjgo60/ljFghZgwXBdMgMLcmhcAgk90uooMg/oYHDdRDHDQJ 1R3ycGICw4xx/mMalz/qv2AWZsSBVZtXR8Wd8piQNjM9k+9n+Dz7EGlDvlPRfyfxZEv01dBSIbH AnR4= X-Google-Smtp-Source: AGHT+IHd4UOpxzBPFDAw4SCSZ1+He9gU8L0hFeeHtd/CLCVk5s1ek3dop3ZOhk7o2k0W426VymLROQ== X-Received: by 2002:a92:d24d:0:b0:361:ae2c:f8c3 with SMTP id v13-20020a92d24d000000b00361ae2cf8c3mr3298337ilg.52.1705796468694; Sat, 20 Jan 2024 16:21:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Michael Tokarev , Thomas Huth Subject: [PULL 5/8] tests/tcg/s390x: Import linux tools/testing/crypto/chacha20-s390 Date: Sun, 21 Jan 2024 11:20:44 +1100 Message-Id: <20240121002047.89234-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121002047.89234-1-richard.henderson@linaro.org> References: <20240121002047.89234-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::d2c; envelope-from=richard.henderson@linaro.org; helo=mail-io1-xd2c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705796551727100003 Content-Type: text/plain; charset="utf-8" Modify and simplify the driver, as we're really only interested in correctness of translation of chacha-vx.S. Tested-by: Michael Tokarev Tested-by: Thomas Huth Message-Id: <20240117213646.159697-3-richard.henderson@linaro.org> Signed-off-by: Richard Henderson --- tests/tcg/s390x/chacha.c | 341 ++++++++++++ tests/tcg/s390x/Makefile.target | 4 + tests/tcg/s390x/chacha-vx.S | 914 ++++++++++++++++++++++++++++++++ 3 files changed, 1259 insertions(+) create mode 100644 tests/tcg/s390x/chacha.c create mode 100644 tests/tcg/s390x/chacha-vx.S diff --git a/tests/tcg/s390x/chacha.c b/tests/tcg/s390x/chacha.c new file mode 100644 index 0000000000..ca9e4c1959 --- /dev/null +++ b/tests/tcg/s390x/chacha.c @@ -0,0 +1,341 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Derived from linux kernel sources: + * ./include/crypto/chacha.h + * ./crypto/chacha_generic.c + * ./arch/s390/crypto/chacha-glue.c + * ./tools/testing/crypto/chacha20-s390/test-cipher.c + * ./tools/testing/crypto/chacha20-s390/run-tests.sh + */ + +#include +#include +#include +#include +#include +#include + +typedef uint8_t u8; +typedef uint32_t u32; +typedef uint64_t u64; + +static unsigned data_size; +static bool debug; + +#define CHACHA_IV_SIZE 16 +#define CHACHA_KEY_SIZE 32 +#define CHACHA_BLOCK_SIZE 64 +#define CHACHAPOLY_IV_SIZE 12 +#define CHACHA_STATE_WORDS (CHACHA_BLOCK_SIZE / sizeof(u32)) + +static u32 rol32(u32 val, u32 sh) +{ + return (val << (sh & 31)) | (val >> (-sh & 31)); +} + +static u32 get_unaligned_le32(const void *ptr) +{ + u32 val; + memcpy(&val, ptr, 4); + return __builtin_bswap32(val); +} + +static void put_unaligned_le32(u32 val, void *ptr) +{ + val =3D __builtin_bswap32(val); + memcpy(ptr, &val, 4); +} + +static void chacha_permute(u32 *x, int nrounds) +{ + for (int i =3D 0; i < nrounds; i +=3D 2) { + x[0] +=3D x[4]; x[12] =3D rol32(x[12] ^ x[0], 16); + x[1] +=3D x[5]; x[13] =3D rol32(x[13] ^ x[1], 16); + x[2] +=3D x[6]; x[14] =3D rol32(x[14] ^ x[2], 16); + x[3] +=3D x[7]; x[15] =3D rol32(x[15] ^ x[3], 16); + + x[8] +=3D x[12]; x[4] =3D rol32(x[4] ^ x[8], 12); + x[9] +=3D x[13]; x[5] =3D rol32(x[5] ^ x[9], 12); + x[10] +=3D x[14]; x[6] =3D rol32(x[6] ^ x[10], 12); + x[11] +=3D x[15]; x[7] =3D rol32(x[7] ^ x[11], 12); + + x[0] +=3D x[4]; x[12] =3D rol32(x[12] ^ x[0], 8); + x[1] +=3D x[5]; x[13] =3D rol32(x[13] ^ x[1], 8); + x[2] +=3D x[6]; x[14] =3D rol32(x[14] ^ x[2], 8); + x[3] +=3D x[7]; x[15] =3D rol32(x[15] ^ x[3], 8); + + x[8] +=3D x[12]; x[4] =3D rol32(x[4] ^ x[8], 7); + x[9] +=3D x[13]; x[5] =3D rol32(x[5] ^ x[9], 7); + x[10] +=3D x[14]; x[6] =3D rol32(x[6] ^ x[10], 7); + x[11] +=3D x[15]; x[7] =3D rol32(x[7] ^ x[11], 7); + + x[0] +=3D x[5]; x[15] =3D rol32(x[15] ^ x[0], 16); + x[1] +=3D x[6]; x[12] =3D rol32(x[12] ^ x[1], 16); + x[2] +=3D x[7]; x[13] =3D rol32(x[13] ^ x[2], 16); + x[3] +=3D x[4]; x[14] =3D rol32(x[14] ^ x[3], 16); + + x[10] +=3D x[15]; x[5] =3D rol32(x[5] ^ x[10], 12); + x[11] +=3D x[12]; x[6] =3D rol32(x[6] ^ x[11], 12); + x[8] +=3D x[13]; x[7] =3D rol32(x[7] ^ x[8], 12); + x[9] +=3D x[14]; x[4] =3D rol32(x[4] ^ x[9], 12); + + x[0] +=3D x[5]; x[15] =3D rol32(x[15] ^ x[0], 8); + x[1] +=3D x[6]; x[12] =3D rol32(x[12] ^ x[1], 8); + x[2] +=3D x[7]; x[13] =3D rol32(x[13] ^ x[2], 8); + x[3] +=3D x[4]; x[14] =3D rol32(x[14] ^ x[3], 8); + + x[10] +=3D x[15]; x[5] =3D rol32(x[5] ^ x[10], 7); + x[11] +=3D x[12]; x[6] =3D rol32(x[6] ^ x[11], 7); + x[8] +=3D x[13]; x[7] =3D rol32(x[7] ^ x[8], 7); + x[9] +=3D x[14]; x[4] =3D rol32(x[4] ^ x[9], 7); + } +} + +static void chacha_block_generic(u32 *state, u8 *stream, int nrounds) +{ + u32 x[16]; + + memcpy(x, state, 64); + chacha_permute(x, nrounds); + + for (int i =3D 0; i < 16; i++) { + put_unaligned_le32(x[i] + state[i], &stream[i * sizeof(u32)]); + } + state[12]++; +} + +static void crypto_xor_cpy(u8 *dst, const u8 *src1, + const u8 *src2, unsigned len) +{ + while (len--) { + *dst++ =3D *src1++ ^ *src2++; + } +} + +static void chacha_crypt_generic(u32 *state, u8 *dst, const u8 *src, + unsigned int bytes, int nrounds) +{ + u8 stream[CHACHA_BLOCK_SIZE]; + + while (bytes >=3D CHACHA_BLOCK_SIZE) { + chacha_block_generic(state, stream, nrounds); + crypto_xor_cpy(dst, src, stream, CHACHA_BLOCK_SIZE); + bytes -=3D CHACHA_BLOCK_SIZE; + dst +=3D CHACHA_BLOCK_SIZE; + src +=3D CHACHA_BLOCK_SIZE; + } + if (bytes) { + chacha_block_generic(state, stream, nrounds); + crypto_xor_cpy(dst, src, stream, bytes); + } +} + +enum chacha_constants { /* expand 32-byte k */ + CHACHA_CONSTANT_EXPA =3D 0x61707865U, + CHACHA_CONSTANT_ND_3 =3D 0x3320646eU, + CHACHA_CONSTANT_2_BY =3D 0x79622d32U, + CHACHA_CONSTANT_TE_K =3D 0x6b206574U +}; + +static void chacha_init_generic(u32 *state, const u32 *key, const u8 *iv) +{ + state[0] =3D CHACHA_CONSTANT_EXPA; + state[1] =3D CHACHA_CONSTANT_ND_3; + state[2] =3D CHACHA_CONSTANT_2_BY; + state[3] =3D CHACHA_CONSTANT_TE_K; + state[4] =3D key[0]; + state[5] =3D key[1]; + state[6] =3D key[2]; + state[7] =3D key[3]; + state[8] =3D key[4]; + state[9] =3D key[5]; + state[10] =3D key[6]; + state[11] =3D key[7]; + state[12] =3D get_unaligned_le32(iv + 0); + state[13] =3D get_unaligned_le32(iv + 4); + state[14] =3D get_unaligned_le32(iv + 8); + state[15] =3D get_unaligned_le32(iv + 12); +} + +void chacha20_vx(u8 *out, const u8 *inp, size_t len, const u32 *key, + const u32 *counter); + +static void chacha20_crypt_s390(u32 *state, u8 *dst, const u8 *src, + unsigned int nbytes, const u32 *key, + u32 *counter) +{ + chacha20_vx(dst, src, nbytes, key, counter); + *counter +=3D (nbytes + CHACHA_BLOCK_SIZE - 1) / CHACHA_BLOCK_SIZE; +} + +static void chacha_crypt_arch(u32 *state, u8 *dst, const u8 *src, + unsigned int bytes, int nrounds) +{ + /* + * s390 chacha20 implementation has 20 rounds hard-coded, + * it cannot handle a block of data or less, but otherwise + * it can handle data of arbitrary size + */ + if (bytes <=3D CHACHA_BLOCK_SIZE || nrounds !=3D 20) { + chacha_crypt_generic(state, dst, src, bytes, nrounds); + } else { + chacha20_crypt_s390(state, dst, src, bytes, &state[4], &state[12]); + } +} + +static void print_hex_dump(const char *prefix_str, const void *buf, int le= n) +{ + for (int i =3D 0; i < len; i +=3D 16) { + printf("%s%.8x: ", prefix_str, i); + for (int j =3D 0; j < 16; ++j) { + printf("%02x%c", *(u8 *)(buf + i + j), j =3D=3D 15 ? '\n' : ' = '); + } + } +} + +/* Perform cipher operations with the chacha lib */ +static int test_lib_chacha(u8 *revert, u8 *cipher, u8 *plain, bool generic) +{ + u32 chacha_state[CHACHA_STATE_WORDS]; + u8 iv[16], key[32]; + + memset(key, 'X', sizeof(key)); + memset(iv, 'I', sizeof(iv)); + + if (debug) { + print_hex_dump("key: ", key, 32); + print_hex_dump("iv: ", iv, 16); + } + + /* Encrypt */ + chacha_init_generic(chacha_state, (u32*)key, iv); + + if (generic) { + chacha_crypt_generic(chacha_state, cipher, plain, data_size, 20); + } else { + chacha_crypt_arch(chacha_state, cipher, plain, data_size, 20); + } + + if (debug) { + print_hex_dump("encr:", cipher, + (data_size > 64 ? 64 : data_size)); + } + + /* Decrypt */ + chacha_init_generic(chacha_state, (u32 *)key, iv); + + if (generic) { + chacha_crypt_generic(chacha_state, revert, cipher, data_size, 20); + } else { + chacha_crypt_arch(chacha_state, revert, cipher, data_size, 20); + } + + if (debug) { + print_hex_dump("decr:", revert, + (data_size > 64 ? 64 : data_size)); + } + return 0; +} + +static int chacha_s390_test_init(void) +{ + u8 *plain =3D NULL, *revert =3D NULL; + u8 *cipher_generic =3D NULL, *cipher_s390 =3D NULL; + int ret =3D -1; + + printf("s390 ChaCha20 test module: size=3D%d debug=3D%d\n", + data_size, debug); + + /* Allocate and fill buffers */ + plain =3D malloc(data_size); + if (!plain) { + printf("could not allocate plain buffer\n"); + ret =3D -2; + goto out; + } + + memset(plain, 'a', data_size); + for (unsigned i =3D 0, n =3D data_size > 256 ? 256 : data_size; i < n;= ) { + ssize_t t =3D getrandom(plain + i, n - i, 0); + if (t < 0) { + break; + } + i -=3D t; + } + + cipher_generic =3D calloc(1, data_size); + if (!cipher_generic) { + printf("could not allocate cipher_generic buffer\n"); + ret =3D -2; + goto out; + } + + cipher_s390 =3D calloc(1, data_size); + if (!cipher_s390) { + printf("could not allocate cipher_s390 buffer\n"); + ret =3D -2; + goto out; + } + + revert =3D calloc(1, data_size); + if (!revert) { + printf("could not allocate revert buffer\n"); + ret =3D -2; + goto out; + } + + if (debug) { + print_hex_dump("src: ", plain, + (data_size > 64 ? 64 : data_size)); + } + + /* Use chacha20 lib */ + test_lib_chacha(revert, cipher_generic, plain, true); + if (memcmp(plain, revert, data_size)) { + printf("generic en/decryption check FAILED\n"); + ret =3D -2; + goto out; + } + printf("generic en/decryption check OK\n"); + + test_lib_chacha(revert, cipher_s390, plain, false); + if (memcmp(plain, revert, data_size)) { + printf("lib en/decryption check FAILED\n"); + ret =3D -2; + goto out; + } + printf("lib en/decryption check OK\n"); + + if (memcmp(cipher_generic, cipher_s390, data_size)) { + printf("lib vs generic check FAILED\n"); + ret =3D -2; + goto out; + } + printf("lib vs generic check OK\n"); + + printf("--- chacha20 s390 test end ---\n"); + +out: + free(plain); + free(cipher_generic); + free(cipher_s390); + free(revert); + return ret; +} + +int main(int ac, char **av) +{ + static const unsigned sizes[] =3D { + 63, 64, 65, 127, 128, 129, 511, 512, 513, 4096, 65611, + /* too slow for tcg: 6291456, 62914560 */ + }; + + debug =3D ac >=3D 2; + for (int i =3D 0; i < sizeof(sizes) / sizeof(sizes[0]); ++i) { + data_size =3D sizes[i]; + if (chacha_s390_test_init() !=3D -1) { + return 1; + } + } + return 0; +} diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.tar= get index 30994dcf9c..b9dc12dc8a 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -66,9 +66,13 @@ Z13_TESTS+=3Dvcksm Z13_TESTS+=3Dvstl Z13_TESTS+=3Dvrep Z13_TESTS+=3Dprecise-smc-user +Z13_TESTS+=3Dchacha $(Z13_TESTS): CFLAGS+=3D-march=3Dz13 -O2 TESTS+=3D$(Z13_TESTS) =20 +chacha: chacha.c chacha-vx.S + $(CC) $(LDFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) $^ -o $@ + ifneq ($(CROSS_CC_HAS_Z14),) Z14_TESTS=3Dvfminmax vfminmax: LDFLAGS+=3D-lm diff --git a/tests/tcg/s390x/chacha-vx.S b/tests/tcg/s390x/chacha-vx.S new file mode 100644 index 0000000000..dcb55b4324 --- /dev/null +++ b/tests/tcg/s390x/chacha-vx.S @@ -0,0 +1,914 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Original implementation written by Andy Polyakov, @dot-asm. + * This is an adaptation of the original code for kernel use. + * + * Copyright (C) 2006-2019 CRYPTOGAMS by . All Rights R= eserved. + * + * For qemu testing, drop and assume assembler support. + */ + +#define SP %r15 +#define FRAME (16 * 8 + 4 * 8) + + .data + .balign 32 + +sigma: + .long 0x61707865,0x3320646e,0x79622d32,0x6b206574 # endian-neutral + .long 1,0,0,0 + .long 2,0,0,0 + .long 3,0,0,0 + .long 0x03020100,0x07060504,0x0b0a0908,0x0f0e0d0c # byte swap + + .long 0,1,2,3 + .long 0x61707865,0x61707865,0x61707865,0x61707865 # smashed sigma + .long 0x3320646e,0x3320646e,0x3320646e,0x3320646e + .long 0x79622d32,0x79622d32,0x79622d32,0x79622d32 + .long 0x6b206574,0x6b206574,0x6b206574,0x6b206574 + + .type sigma, @object + .size sigma, . - sigma + + .previous + + .text + +##########################################################################= ### +# void chacha20_vx_4x(u8 *out, counst u8 *inp, size_t len, +# counst u32 *key, const u32 *counter) + +#define OUT %r2 +#define INP %r3 +#define LEN %r4 +#define KEY %r5 +#define COUNTER %r6 + +#define BEPERM %v31 +#define CTR %v26 + +#define K0 %v16 +#define K1 %v17 +#define K2 %v18 +#define K3 %v19 + +#define XA0 %v0 +#define XA1 %v1 +#define XA2 %v2 +#define XA3 %v3 + +#define XB0 %v4 +#define XB1 %v5 +#define XB2 %v6 +#define XB3 %v7 + +#define XC0 %v8 +#define XC1 %v9 +#define XC2 %v10 +#define XC3 %v11 + +#define XD0 %v12 +#define XD1 %v13 +#define XD2 %v14 +#define XD3 %v15 + +#define XT0 %v27 +#define XT1 %v28 +#define XT2 %v29 +#define XT3 %v30 + + .balign 32 +chacha20_vx_4x: + stmg %r6,%r7,6*8(SP) + + larl %r7,sigma + lhi %r0,10 + lhi %r1,0 + + vl K0,0(%r7) # load sigma + vl K1,0(KEY) # load key + vl K2,16(KEY) + vl K3,0(COUNTER) # load counter + + vl BEPERM,0x40(%r7) + vl CTR,0x50(%r7) + + vlm XA0,XA3,0x60(%r7),4 # load [smashed] sigma + + vrepf XB0,K1,0 # smash the key + vrepf XB1,K1,1 + vrepf XB2,K1,2 + vrepf XB3,K1,3 + + vrepf XD0,K3,0 + vrepf XD1,K3,1 + vrepf XD2,K3,2 + vrepf XD3,K3,3 + vaf XD0,XD0,CTR + + vrepf XC0,K2,0 + vrepf XC1,K2,1 + vrepf XC2,K2,2 + vrepf XC3,K2,3 + +.Loop_4x: + vaf XA0,XA0,XB0 + vx XD0,XD0,XA0 + verllf XD0,XD0,16 + + vaf XA1,XA1,XB1 + vx XD1,XD1,XA1 + verllf XD1,XD1,16 + + vaf XA2,XA2,XB2 + vx XD2,XD2,XA2 + verllf XD2,XD2,16 + + vaf XA3,XA3,XB3 + vx XD3,XD3,XA3 + verllf XD3,XD3,16 + + vaf XC0,XC0,XD0 + vx XB0,XB0,XC0 + verllf XB0,XB0,12 + + vaf XC1,XC1,XD1 + vx XB1,XB1,XC1 + verllf XB1,XB1,12 + + vaf XC2,XC2,XD2 + vx XB2,XB2,XC2 + verllf XB2,XB2,12 + + vaf XC3,XC3,XD3 + vx XB3,XB3,XC3 + verllf XB3,XB3,12 + + vaf XA0,XA0,XB0 + vx XD0,XD0,XA0 + verllf XD0,XD0,8 + + vaf XA1,XA1,XB1 + vx XD1,XD1,XA1 + verllf XD1,XD1,8 + + vaf XA2,XA2,XB2 + vx XD2,XD2,XA2 + verllf XD2,XD2,8 + + vaf XA3,XA3,XB3 + vx XD3,XD3,XA3 + verllf XD3,XD3,8 + + vaf XC0,XC0,XD0 + vx XB0,XB0,XC0 + verllf XB0,XB0,7 + + vaf XC1,XC1,XD1 + vx XB1,XB1,XC1 + verllf XB1,XB1,7 + + vaf XC2,XC2,XD2 + vx XB2,XB2,XC2 + verllf XB2,XB2,7 + + vaf XC3,XC3,XD3 + vx XB3,XB3,XC3 + verllf XB3,XB3,7 + + vaf XA0,XA0,XB1 + vx XD3,XD3,XA0 + verllf XD3,XD3,16 + + vaf XA1,XA1,XB2 + vx XD0,XD0,XA1 + verllf XD0,XD0,16 + + vaf XA2,XA2,XB3 + vx XD1,XD1,XA2 + verllf XD1,XD1,16 + + vaf XA3,XA3,XB0 + vx XD2,XD2,XA3 + verllf XD2,XD2,16 + + vaf XC2,XC2,XD3 + vx XB1,XB1,XC2 + verllf XB1,XB1,12 + + vaf XC3,XC3,XD0 + vx XB2,XB2,XC3 + verllf XB2,XB2,12 + + vaf XC0,XC0,XD1 + vx XB3,XB3,XC0 + verllf XB3,XB3,12 + + vaf XC1,XC1,XD2 + vx XB0,XB0,XC1 + verllf XB0,XB0,12 + + vaf XA0,XA0,XB1 + vx XD3,XD3,XA0 + verllf XD3,XD3,8 + + vaf XA1,XA1,XB2 + vx XD0,XD0,XA1 + verllf XD0,XD0,8 + + vaf XA2,XA2,XB3 + vx XD1,XD1,XA2 + verllf XD1,XD1,8 + + vaf XA3,XA3,XB0 + vx XD2,XD2,XA3 + verllf XD2,XD2,8 + + vaf XC2,XC2,XD3 + vx XB1,XB1,XC2 + verllf XB1,XB1,7 + + vaf XC3,XC3,XD0 + vx XB2,XB2,XC3 + verllf XB2,XB2,7 + + vaf XC0,XC0,XD1 + vx XB3,XB3,XC0 + verllf XB3,XB3,7 + + vaf XC1,XC1,XD2 + vx XB0,XB0,XC1 + verllf XB0,XB0,7 + brct %r0,.Loop_4x + + vaf XD0,XD0,CTR + + vmrhf XT0,XA0,XA1 # transpose data + vmrhf XT1,XA2,XA3 + vmrlf XT2,XA0,XA1 + vmrlf XT3,XA2,XA3 + vpdi XA0,XT0,XT1,0b0000 + vpdi XA1,XT0,XT1,0b0101 + vpdi XA2,XT2,XT3,0b0000 + vpdi XA3,XT2,XT3,0b0101 + + vmrhf XT0,XB0,XB1 + vmrhf XT1,XB2,XB3 + vmrlf XT2,XB0,XB1 + vmrlf XT3,XB2,XB3 + vpdi XB0,XT0,XT1,0b0000 + vpdi XB1,XT0,XT1,0b0101 + vpdi XB2,XT2,XT3,0b0000 + vpdi XB3,XT2,XT3,0b0101 + + vmrhf XT0,XC0,XC1 + vmrhf XT1,XC2,XC3 + vmrlf XT2,XC0,XC1 + vmrlf XT3,XC2,XC3 + vpdi XC0,XT0,XT1,0b0000 + vpdi XC1,XT0,XT1,0b0101 + vpdi XC2,XT2,XT3,0b0000 + vpdi XC3,XT2,XT3,0b0101 + + vmrhf XT0,XD0,XD1 + vmrhf XT1,XD2,XD3 + vmrlf XT2,XD0,XD1 + vmrlf XT3,XD2,XD3 + vpdi XD0,XT0,XT1,0b0000 + vpdi XD1,XT0,XT1,0b0101 + vpdi XD2,XT2,XT3,0b0000 + vpdi XD3,XT2,XT3,0b0101 + + vaf XA0,XA0,K0 + vaf XB0,XB0,K1 + vaf XC0,XC0,K2 + vaf XD0,XD0,K3 + + vperm XA0,XA0,XA0,BEPERM + vperm XB0,XB0,XB0,BEPERM + vperm XC0,XC0,XC0,BEPERM + vperm XD0,XD0,XD0,BEPERM + + vlm XT0,XT3,0(INP),0 + + vx XT0,XT0,XA0 + vx XT1,XT1,XB0 + vx XT2,XT2,XC0 + vx XT3,XT3,XD0 + + vstm XT0,XT3,0(OUT),0 + + la INP,0x40(INP) + la OUT,0x40(OUT) + aghi LEN,-0x40 + + vaf XA0,XA1,K0 + vaf XB0,XB1,K1 + vaf XC0,XC1,K2 + vaf XD0,XD1,K3 + + vperm XA0,XA0,XA0,BEPERM + vperm XB0,XB0,XB0,BEPERM + vperm XC0,XC0,XC0,BEPERM + vperm XD0,XD0,XD0,BEPERM + + clgfi LEN,0x40 + jl .Ltail_4x + + vlm XT0,XT3,0(INP),0 + + vx XT0,XT0,XA0 + vx XT1,XT1,XB0 + vx XT2,XT2,XC0 + vx XT3,XT3,XD0 + + vstm XT0,XT3,0(OUT),0 + + la INP,0x40(INP) + la OUT,0x40(OUT) + aghi LEN,-0x40 + je .Ldone_4x + + vaf XA0,XA2,K0 + vaf XB0,XB2,K1 + vaf XC0,XC2,K2 + vaf XD0,XD2,K3 + + vperm XA0,XA0,XA0,BEPERM + vperm XB0,XB0,XB0,BEPERM + vperm XC0,XC0,XC0,BEPERM + vperm XD0,XD0,XD0,BEPERM + + clgfi LEN,0x40 + jl .Ltail_4x + + vlm XT0,XT3,0(INP),0 + + vx XT0,XT0,XA0 + vx XT1,XT1,XB0 + vx XT2,XT2,XC0 + vx XT3,XT3,XD0 + + vstm XT0,XT3,0(OUT),0 + + la INP,0x40(INP) + la OUT,0x40(OUT) + aghi LEN,-0x40 + je .Ldone_4x + + vaf XA0,XA3,K0 + vaf XB0,XB3,K1 + vaf XC0,XC3,K2 + vaf XD0,XD3,K3 + + vperm XA0,XA0,XA0,BEPERM + vperm XB0,XB0,XB0,BEPERM + vperm XC0,XC0,XC0,BEPERM + vperm XD0,XD0,XD0,BEPERM + + clgfi LEN,0x40 + jl .Ltail_4x + + vlm XT0,XT3,0(INP),0 + + vx XT0,XT0,XA0 + vx XT1,XT1,XB0 + vx XT2,XT2,XC0 + vx XT3,XT3,XD0 + + vstm XT0,XT3,0(OUT),0 + +.Ldone_4x: + lmg %r6,%r7,6*8(SP) + br %r14 + +.Ltail_4x: + vlr XT0,XC0 + vlr XT1,XD0 + + vst XA0,8*8+0x00(SP) + vst XB0,8*8+0x10(SP) + vst XT0,8*8+0x20(SP) + vst XT1,8*8+0x30(SP) + + lghi %r1,0 + +.Loop_tail_4x: + llgc %r5,0(%r1,INP) + llgc %r6,8*8(%r1,SP) + xr %r6,%r5 + stc %r6,0(%r1,OUT) + la %r1,1(%r1) + brct LEN,.Loop_tail_4x + + lmg %r6,%r7,6*8(SP) + br %r14 + + .type chacha20_vx_4x, @function + .size chacha20_vx_4x, . - chacha20_vx_4x + +#undef OUT +#undef INP +#undef LEN +#undef KEY +#undef COUNTER + +#undef BEPERM + +#undef K0 +#undef K1 +#undef K2 +#undef K3 + + +##########################################################################= ### +# void chacha20_vx(u8 *out, counst u8 *inp, size_t len, +# counst u32 *key, const u32 *counter) + +#define OUT %r2 +#define INP %r3 +#define LEN %r4 +#define KEY %r5 +#define COUNTER %r6 + +#define BEPERM %v31 + +#define K0 %v27 +#define K1 %v24 +#define K2 %v25 +#define K3 %v26 + +#define A0 %v0 +#define B0 %v1 +#define C0 %v2 +#define D0 %v3 + +#define A1 %v4 +#define B1 %v5 +#define C1 %v6 +#define D1 %v7 + +#define A2 %v8 +#define B2 %v9 +#define C2 %v10 +#define D2 %v11 + +#define A3 %v12 +#define B3 %v13 +#define C3 %v14 +#define D3 %v15 + +#define A4 %v16 +#define B4 %v17 +#define C4 %v18 +#define D4 %v19 + +#define A5 %v20 +#define B5 %v21 +#define C5 %v22 +#define D5 %v23 + +#define T0 %v27 +#define T1 %v28 +#define T2 %v29 +#define T3 %v30 + + .balign 32 +chacha20_vx: + clgfi LEN,256 + jle chacha20_vx_4x + stmg %r6,%r7,6*8(SP) + + lghi %r1,-FRAME + lgr %r0,SP + la SP,0(%r1,SP) + stg %r0,0(SP) # back-chain + + larl %r7,sigma + lhi %r0,10 + + vlm K1,K2,0(KEY),0 # load key + vl K3,0(COUNTER) # load counter + + vlm K0,BEPERM,0(%r7),4 # load sigma, increments, ... + +.Loop_outer_vx: + vlr A0,K0 + vlr B0,K1 + vlr A1,K0 + vlr B1,K1 + vlr A2,K0 + vlr B2,K1 + vlr A3,K0 + vlr B3,K1 + vlr A4,K0 + vlr B4,K1 + vlr A5,K0 + vlr B5,K1 + + vlr D0,K3 + vaf D1,K3,T1 # K[3]+1 + vaf D2,K3,T2 # K[3]+2 + vaf D3,K3,T3 # K[3]+3 + vaf D4,D2,T2 # K[3]+4 + vaf D5,D2,T3 # K[3]+5 + + vlr C0,K2 + vlr C1,K2 + vlr C2,K2 + vlr C3,K2 + vlr C4,K2 + vlr C5,K2 + + vlr T1,D1 + vlr T2,D2 + vlr T3,D3 + +.Loop_vx: + vaf A0,A0,B0 + vaf A1,A1,B1 + vaf A2,A2,B2 + vaf A3,A3,B3 + vaf A4,A4,B4 + vaf A5,A5,B5 + vx D0,D0,A0 + vx D1,D1,A1 + vx D2,D2,A2 + vx D3,D3,A3 + vx D4,D4,A4 + vx D5,D5,A5 + verllf D0,D0,16 + verllf D1,D1,16 + verllf D2,D2,16 + verllf D3,D3,16 + verllf D4,D4,16 + verllf D5,D5,16 + + vaf C0,C0,D0 + vaf C1,C1,D1 + vaf C2,C2,D2 + vaf C3,C3,D3 + vaf C4,C4,D4 + vaf C5,C5,D5 + vx B0,B0,C0 + vx B1,B1,C1 + vx B2,B2,C2 + vx B3,B3,C3 + vx B4,B4,C4 + vx B5,B5,C5 + verllf B0,B0,12 + verllf B1,B1,12 + verllf B2,B2,12 + verllf B3,B3,12 + verllf B4,B4,12 + verllf B5,B5,12 + + vaf A0,A0,B0 + vaf A1,A1,B1 + vaf A2,A2,B2 + vaf A3,A3,B3 + vaf A4,A4,B4 + vaf A5,A5,B5 + vx D0,D0,A0 + vx D1,D1,A1 + vx D2,D2,A2 + vx D3,D3,A3 + vx D4,D4,A4 + vx D5,D5,A5 + verllf D0,D0,8 + verllf D1,D1,8 + verllf D2,D2,8 + verllf D3,D3,8 + verllf D4,D4,8 + verllf D5,D5,8 + + vaf C0,C0,D0 + vaf C1,C1,D1 + vaf C2,C2,D2 + vaf C3,C3,D3 + vaf C4,C4,D4 + vaf C5,C5,D5 + vx B0,B0,C0 + vx B1,B1,C1 + vx B2,B2,C2 + vx B3,B3,C3 + vx B4,B4,C4 + vx B5,B5,C5 + verllf B0,B0,7 + verllf B1,B1,7 + verllf B2,B2,7 + verllf B3,B3,7 + verllf B4,B4,7 + verllf B5,B5,7 + + vsldb C0,C0,C0,8 + vsldb C1,C1,C1,8 + vsldb C2,C2,C2,8 + vsldb C3,C3,C3,8 + vsldb C4,C4,C4,8 + vsldb C5,C5,C5,8 + vsldb B0,B0,B0,4 + vsldb B1,B1,B1,4 + vsldb B2,B2,B2,4 + vsldb B3,B3,B3,4 + vsldb B4,B4,B4,4 + vsldb B5,B5,B5,4 + vsldb D0,D0,D0,12 + vsldb D1,D1,D1,12 + vsldb D2,D2,D2,12 + vsldb D3,D3,D3,12 + vsldb D4,D4,D4,12 + vsldb D5,D5,D5,12 + + vaf A0,A0,B0 + vaf A1,A1,B1 + vaf A2,A2,B2 + vaf A3,A3,B3 + vaf A4,A4,B4 + vaf A5,A5,B5 + vx D0,D0,A0 + vx D1,D1,A1 + vx D2,D2,A2 + vx D3,D3,A3 + vx D4,D4,A4 + vx D5,D5,A5 + verllf D0,D0,16 + verllf D1,D1,16 + verllf D2,D2,16 + verllf D3,D3,16 + verllf D4,D4,16 + verllf D5,D5,16 + + vaf C0,C0,D0 + vaf C1,C1,D1 + vaf C2,C2,D2 + vaf C3,C3,D3 + vaf C4,C4,D4 + vaf C5,C5,D5 + vx B0,B0,C0 + vx B1,B1,C1 + vx B2,B2,C2 + vx B3,B3,C3 + vx B4,B4,C4 + vx B5,B5,C5 + verllf B0,B0,12 + verllf B1,B1,12 + verllf B2,B2,12 + verllf B3,B3,12 + verllf B4,B4,12 + verllf B5,B5,12 + + vaf A0,A0,B0 + vaf A1,A1,B1 + vaf A2,A2,B2 + vaf A3,A3,B3 + vaf A4,A4,B4 + vaf A5,A5,B5 + vx D0,D0,A0 + vx D1,D1,A1 + vx D2,D2,A2 + vx D3,D3,A3 + vx D4,D4,A4 + vx D5,D5,A5 + verllf D0,D0,8 + verllf D1,D1,8 + verllf D2,D2,8 + verllf D3,D3,8 + verllf D4,D4,8 + verllf D5,D5,8 + + vaf C0,C0,D0 + vaf C1,C1,D1 + vaf C2,C2,D2 + vaf C3,C3,D3 + vaf C4,C4,D4 + vaf C5,C5,D5 + vx B0,B0,C0 + vx B1,B1,C1 + vx B2,B2,C2 + vx B3,B3,C3 + vx B4,B4,C4 + vx B5,B5,C5 + verllf B0,B0,7 + verllf B1,B1,7 + verllf B2,B2,7 + verllf B3,B3,7 + verllf B4,B4,7 + verllf B5,B5,7 + + vsldb C0,C0,C0,8 + vsldb C1,C1,C1,8 + vsldb C2,C2,C2,8 + vsldb C3,C3,C3,8 + vsldb C4,C4,C4,8 + vsldb C5,C5,C5,8 + vsldb B0,B0,B0,12 + vsldb B1,B1,B1,12 + vsldb B2,B2,B2,12 + vsldb B3,B3,B3,12 + vsldb B4,B4,B4,12 + vsldb B5,B5,B5,12 + vsldb D0,D0,D0,4 + vsldb D1,D1,D1,4 + vsldb D2,D2,D2,4 + vsldb D3,D3,D3,4 + vsldb D4,D4,D4,4 + vsldb D5,D5,D5,4 + brct %r0,.Loop_vx + + vaf A0,A0,K0 + vaf B0,B0,K1 + vaf C0,C0,K2 + vaf D0,D0,K3 + vaf A1,A1,K0 + vaf D1,D1,T1 # +K[3]+1 + + vperm A0,A0,A0,BEPERM + vperm B0,B0,B0,BEPERM + vperm C0,C0,C0,BEPERM + vperm D0,D0,D0,BEPERM + + clgfi LEN,0x40 + jl .Ltail_vx + + vaf D2,D2,T2 # +K[3]+2 + vaf D3,D3,T3 # +K[3]+3 + vlm T0,T3,0(INP),0 + + vx A0,A0,T0 + vx B0,B0,T1 + vx C0,C0,T2 + vx D0,D0,T3 + + vlm K0,T3,0(%r7),4 # re-load sigma and increments + + vstm A0,D0,0(OUT),0 + + la INP,0x40(INP) + la OUT,0x40(OUT) + aghi LEN,-0x40 + je .Ldone_vx + + vaf B1,B1,K1 + vaf C1,C1,K2 + + vperm A0,A1,A1,BEPERM + vperm B0,B1,B1,BEPERM + vperm C0,C1,C1,BEPERM + vperm D0,D1,D1,BEPERM + + clgfi LEN,0x40 + jl .Ltail_vx + + vlm A1,D1,0(INP),0 + + vx A0,A0,A1 + vx B0,B0,B1 + vx C0,C0,C1 + vx D0,D0,D1 + + vstm A0,D0,0(OUT),0 + + la INP,0x40(INP) + la OUT,0x40(OUT) + aghi LEN,-0x40 + je .Ldone_vx + + vaf A2,A2,K0 + vaf B2,B2,K1 + vaf C2,C2,K2 + + vperm A0,A2,A2,BEPERM + vperm B0,B2,B2,BEPERM + vperm C0,C2,C2,BEPERM + vperm D0,D2,D2,BEPERM + + clgfi LEN,0x40 + jl .Ltail_vx + + vlm A1,D1,0(INP),0 + + vx A0,A0,A1 + vx B0,B0,B1 + vx C0,C0,C1 + vx D0,D0,D1 + + vstm A0,D0,0(OUT),0 + + la INP,0x40(INP) + la OUT,0x40(OUT) + aghi LEN,-0x40 + je .Ldone_vx + + vaf A3,A3,K0 + vaf B3,B3,K1 + vaf C3,C3,K2 + vaf D2,K3,T3 # K[3]+3 + + vperm A0,A3,A3,BEPERM + vperm B0,B3,B3,BEPERM + vperm C0,C3,C3,BEPERM + vperm D0,D3,D3,BEPERM + + clgfi LEN,0x40 + jl .Ltail_vx + + vaf D3,D2,T1 # K[3]+4 + VLM A1,D1,0(INP),0 + + vx A0,A0,A1 + vx B0,B0,B1 + vx C0,C0,C1 + vx D0,D0,D1 + + vstm A0,D0,0(OUT),0 + + la INP,0x40(INP) + la OUT,0x40(OUT) + aghi LEN,-0x40 + je .Ldone_vx + + vaf A4,A4,K0 + vaf B4,B4,K1 + vaf C4,C4,K2 + vaf D4,D4,D3 # +K[3]+4 + vaf D3,D3,T1 # K[3]+5 + vaf K3,D2,T3 # K[3]+=3D6 + + vperm A0,A4,A4,BEPERM + vperm B0,B4,B4,BEPERM + vperm C0,C4,C4,BEPERM + vperm D0,D4,D4,BEPERM + + clgfi LEN,0x40 + jl .Ltail_vx + + vlm A1,D1,0(INP),0 + + vx A0,A0,A1 + vx B0,B0,B1 + vx C0,C0,C1 + vx D0,D0,D1 + + vstm A0,D0,0(OUT),0 + + la INP,0x40(INP) + la OUT,0x40(OUT) + aghi LEN,-0x40 + je .Ldone_vx + + vaf A5,A5,K0 + vaf B5,B5,K1 + vaf C5,C5,K2 + vaf D5,D5,D3 # +K[3]+5 + + vperm A0,A5,A5,BEPERM + vperm B0,B5,B5,BEPERM + vperm C0,C5,C5,BEPERM + vperm D0,D5,D5,BEPERM + + clgfi LEN,0x40 + jl .Ltail_vx + + vlm A1,D1,0(INP),0 + + vx A0,A0,A1 + vx B0,B0,B1 + vx C0,C0,C1 + vx D0,D0,D1 + + vstm A0,D0,0(OUT),0 + + la INP,0x40(INP) + la OUT,0x40(OUT) + lhi %r0,10 + aghi LEN,-0x40 + jne .Loop_outer_vx + +.Ldone_vx: + lmg %r6,%r7,FRAME+6*8(SP) + la SP,FRAME(SP) + br %r14 + +.Ltail_vx: + vstm A0,D0,8*8(SP),3 + lghi %r1,0 + +.Loop_tail_vx: + llgc %r5,0(%r1,INP) + llgc %r6,8*8(%r1,SP) + xr %r6,%r5 + stc %r6,0(%r1,OUT) + la %r1,1(%r1) + brct LEN,.Loop_tail_vx + + lmg %r6,%r7,FRAME+6*8(SP) + la SP,FRAME(SP) + br %r14 + + .type chacha20_vx, @function + .size chacha20_vx, . - chacha20_vx + .globl chacha20_vx + +.previous +.section .note.GNU-stack,"",%progbits --=20 2.34.1 From nobody Tue Nov 26 17:27:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705796565; cv=none; d=zohomail.com; s=zohoarc; b=gLRU3awxlY7dHvcwi3VJg+sJe82b0LY3oejmn60oaZuec4HUVtxbL71EUaHfNa75MkJFlPKY0JV0vCaE6UqTBfVwY1LV5D5kMy1BvzwxNyJOOP/HftllnCYQDxnTGn/chmkPQjNYF5yJ54uCPjsUEKzM17PiXh8XUyaXgLoHdSY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705796565; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9Xu/nq6hQa8ZLXYCRSmO5dgODT19xrskc9XyMf3C3fg=; b=d0YlFobtLu5VpApsj+7XYKi6nuvihaZmGkmzZCEV2bniWI/GCtJwWI248hJUQBC4jQSO16q8k+N33EsixI8AnmQyzP5p+hgL591854poCSX1jh+U4SO7wAReRi+OAvkhqaxr4ND7Q4PEBllKzWNBU7lI4xxRL24xdkiP6HB+mhA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705796565408120.31342946640666; Sat, 20 Jan 2024 16:22:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rRLaO-0002YT-QF; Sat, 20 Jan 2024 19:21:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rRLaM-0002Xu-IV for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:15 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rRLaK-0007QS-Lc for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:14 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d70c3c2212so13633335ad.1 for ; Sat, 20 Jan 2024 16:21:12 -0800 (PST) Received: from stoup.net ([2001:8004:5170:1e39:1361:3840:4873:7990]) by smtp.gmail.com with ESMTPSA id j4-20020a17090276c400b001d5af7fbda0sm5023546plt.122.2024.01.20.16.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 16:21:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705796471; x=1706401271; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9Xu/nq6hQa8ZLXYCRSmO5dgODT19xrskc9XyMf3C3fg=; b=Lh/EN2ESLax+74ILHQBcm1S3B7ftNg9aSWElRluOvgCpPyL0jmSSkr0uZtSzc01GnM dh1aOdgFEZ2JFWjalR0ZmknGa2HdhByJe1L2kEoU2Nl4VW9a4VBAB+EhOmOd3Nlp0s+3 5W37GqMe19udQ3/6v6nXCHms1pZMOAjTcXnb4F7tNxxWlkh7yLUvt9dT9YEHm5iXfz1k GA1yC8smVNHSRODsvjLzP85QSybcUbZCqpGbIFvAICkisymd96kXmiPknOi6jnoTELs0 EbOPpLwM+QdxIhIJijpO+64BCfzswFbtw+czPPVqX7RAGwAf48d4wTND4sWhm5xxG9AH J0jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705796471; x=1706401271; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9Xu/nq6hQa8ZLXYCRSmO5dgODT19xrskc9XyMf3C3fg=; b=OsT2Xw0zaa4v8oelyYwH/eTL1GqYXvUUl/irgutLhSUCNFzmxzVgkmbjFZvlCQOwfG C3wFMXnN5HN8M6/sDF17b8aaUmkZJe+4nbnQODczqI/+pUJWpqz7XU0EaqIJWsGRcLtl MIqthVA/bPvoPpONFK+wSHyTRaKfcO3w/0/Bo0tDjYnBvAyY9BOqnH/fxn5yqa0t7GAG 0lMazKZ7mMc/j4tps4jV6ewJKmc3zZFmnG01HSAFx/lidT+d+6eGaQ3mF9BC/wIyW8YM uBMSPGKjey4dTxNK2GUySZepRU/tsxYnaUvsARu+twTTAthO0A4I23MfKDKkcMAvK6t4 cUtA== X-Gm-Message-State: AOJu0Yw8Dzhqfb8kVoy8dF7r24+1UVtCArfOhsy3s62rWyJLVBRX/hip m7whCbhbIVVfw17lmMI7G78VYa1BXF0UnnjWETfhUQvSqnhjr+vzC4a29RU1txBDXWQoKbZTkf9 FTzc= X-Google-Smtp-Source: AGHT+IEem+jvjzC524AtxbbSrrGHAFmH3lzMPvQARvb/yn1qdjdHqZwk8dSZ/oEGiBjL+Xozilqi5g== X-Received: by 2002:a17:903:2306:b0:1d3:f344:6b01 with SMTP id d6-20020a170903230600b001d3f3446b01mr2831284plh.3.1705796471153; Sat, 20 Jan 2024 16:21:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Vineet Gupta Subject: [PULL 6/8] linux-user/riscv: Adjust vdso signal frame cfa offsets Date: Sun, 21 Jan 2024 11:20:45 +1100 Message-Id: <20240121002047.89234-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121002047.89234-1-richard.henderson@linaro.org> References: <20240121002047.89234-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705796565684100003 Content-Type: text/plain; charset="utf-8" A typo in sizeof_reg put the registers at the wrong offset. Simplify the expressions to use positive addresses from the start of uc_mcontext instead of negative addresses from the end of uc_mcontext. Reported-by: Vineet Gupta Signed-off-by: Richard Henderson --- linux-user/riscv/vdso-32.so | Bin 2900 -> 2980 bytes linux-user/riscv/vdso-64.so | Bin 3856 -> 3944 bytes linux-user/riscv/vdso.S | 8 ++++---- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/linux-user/riscv/vdso-32.so b/linux-user/riscv/vdso-32.so index 1ad1e5cbbbb8b1fe36b0fe4bcb6c06fab8219ecd..c2ce2a4757900a16b891bb98f7a= 027ac30c47a5f 100755 GIT binary patch delta 643 zcmYjPOH5Ni6ur|gwzc+9XhF0TMNp`GR6Zh~mKGzXLQ}j z)#}rFqIBkAs)(L%{#f{&3ii(}e_yh8Pgey7+LRKpj+~BYkcbM&LN$yL<+mtroa4HJ zZMB#&#N4vYgN#$Ed?)jGwn>u^j$uL6%5;@6#JIs26v~>`CEXn6`%uX09<>tLIBejZ zFY)AcUK{^`w8`*U60=3D@WX3@OR=3D)D9Xp?Lu9eduPPPr;Cc@g53huwxpgyD;B@WePiQ z!+Hz5CSkh?Bv5z*_UkB`K=3DC*n*Cd=3D*Q4&Y#73{u@vN7x##oicPmry ze%vHqR9p0zd0b`2Q|4;3R+vXr`7g}X=3D20v*GSM6w@2yKvwky9(Ht|*2WbKiW=3D;xN^G26tL(qVS~ E1D4W)y8r+H delta 565 zcmZ1?eno780^^#AispCEGBkVi#XS5FJ{d(y6ALK`0fjZ#F<&4uOCj9 zVB90Pf`x%0f`NfSh=3DGSe3rO=3D!e#$6sXaLm50TmSm(hNX850vi%q*ajQ?SOoV&8AHG zjA8N59(ymx)f3 z946aMv6*T$&0@OQ43n8gvkYeI&C!{wHBV!{+5(q_PELy)7TYbcS!%V+V!7E0la)rR z3|8x{(OIjtPGh~=3D29=3DFUn-n(7ZIRh3wM}BX*bb4MLc0WZ^X=3Di;%e9YVKO5Mwb2h(Z zS%t*xcjTq|2?Y1y{IoJiPMVG&Z%B2pwIB5I9(EFvNz z?)pL^MhuHse{pSyL_`lkFFpi~An2jTdJL*3ANrQJmv!LB`8el0AAG-~d%k&ezwB?w z2F6$=3Do7t~c%+g;}vY+2KKi``ijg36bKRDF->-VRR@qD&8Un;XH#&qseT&%$Rm2UT< z5wR{OC8yv~N7E5BABJ-bD-Xhz0JX&79!2Xuw2ffZFjf!2GYIbPUycy@b0)t*m;96aGkL08X> zzGUeUrG%_8_LX0>9{X?YDUqp`qVpeCm%D6~@^8O6!(HS))fFn#xbF-%SEEbG?2`}67j2EFQ> zo3}9LFfy7BQ|eju4WV! zVPs&i0SYMq=3D>Q<@1Ed)yJF+U*UjQfLI5JPe5rP#V`Xz00DDVP%r~yjRT`J z57PlQR)-eG#s?tWjs-3YofbJbEw)=3D?v(##t#d5P1CM%6r8LZY@qqA0P zoyK~#4JsRzHYseD+aj}7YMaD%u^l2ig?0(-=3DG()wmunx#evpSj4qh<1k!|y419kyW za5-|gGn!0n6rMbX!-TP6@k;>oa*G zP}TuWFGF&2M1Z-gk@Mz*obD`4Zx|+X@#%5GYydif&z`YjawDHTFrX$M;kzXAEcnEna diff --git a/linux-user/riscv/vdso.S b/linux-user/riscv/vdso.S index a86d8fc488..c37275233a 100644 --- a/linux-user/riscv/vdso.S +++ b/linux-user/riscv/vdso.S @@ -101,12 +101,12 @@ endf __vdso_flush_icache .cfi_startproc simple .cfi_signal_frame =20 -#define sizeof_reg (__riscv_xlen / 4) +#define sizeof_reg (__riscv_xlen / 8) #define sizeof_freg 8 -#define B_GR (offsetof_uc_mcontext - sizeof_rt_sigframe) -#define B_FR (offsetof_uc_mcontext - sizeof_rt_sigframe + offsetof_freg0) +#define B_GR 0 +#define B_FR offsetof_freg0 =20 - .cfi_def_cfa 2, sizeof_rt_sigframe + .cfi_def_cfa 2, offsetof_uc_mcontext =20 /* Return address */ .cfi_return_column 64 --=20 2.34.1 From nobody Tue Nov 26 17:27:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705796570; cv=none; d=zohomail.com; s=zohoarc; b=AJ7gJNU/YJmI+3vxo7DrmsI3hlcdoWF8v3EXqd1YUyLe4YWrZoHIN56k+VfOUSLNhx/lJJR9u+LFGHA4vUvOwhiWdelO4/n9S5mB6VmhX06BT/h6O+MfzSlMbH7giutlwsVuYW0Nz5WQb3pgntQ/9ULP+6ikmHd8UJSe3U2lnXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705796570; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xu2jaDl0CebkWF1EGwbc5gC+5GyuWO8TNdEnyUmyH68=; b=LhafPZ8wrW7vSsDN1IV11L1mIk44Z0v0G9frSqxyOuQANFAzp8sO7i86wmM2dtfxVZRt3jKbo+pC/1YOBH6f8Gk7hqzCfIxgZOUStpi3bNM5USa+RRl30pwn/oHYw1SYHoh5l4YTRGANjRNjNLSq+CIlWkl/dhLM7C82dm/YZYY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705796570893701.088346900007; Sat, 20 Jan 2024 16:22:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rRLaP-0002Yk-IQ; Sat, 20 Jan 2024 19:21:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rRLaO-0002YQ-MY for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:16 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rRLaN-0007Qn-7O for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:16 -0500 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d6fbaaec91so16701885ad.3 for ; Sat, 20 Jan 2024 16:21:14 -0800 (PST) Received: from stoup.net ([2001:8004:5170:1e39:1361:3840:4873:7990]) by smtp.gmail.com with ESMTPSA id j4-20020a17090276c400b001d5af7fbda0sm5023546plt.122.2024.01.20.16.21.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 16:21:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705796473; x=1706401273; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xu2jaDl0CebkWF1EGwbc5gC+5GyuWO8TNdEnyUmyH68=; b=zB1ECvkmgrwdiPenZzDGtE9p4m1jwc6vpFoDjMd1cduNtOx/E929wuuMPYda6+eviD MWW/AKc4H7ENq2NfdjXW2wt5P8NTOD+p0zQULfV4UnQyxqyx6Z8uwZlvxqUK1AdRE0ML lQlz/AcoSmMqEYwmVhzthfFYPTM7CyhVQJi63hKdVRHfG4QYkoDXrzhFEE8kCaltIhAy g6W7iLyTYs2yfI6XN76SVsQfOJlHBujBn80Zp5/7SgtiWgd/UMd/Mqy4KJJnjznV3avi U9eEAvFkB/ADh8e9Thukz2ng9wiLQ2S69tkr/5zvOOPu9tQmTT1qTMZWvOE3oW7yktkJ xq4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705796473; x=1706401273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xu2jaDl0CebkWF1EGwbc5gC+5GyuWO8TNdEnyUmyH68=; b=ewAIsSmCbFXPHmbryPZIuGUJA0hyWjv7s8sk+4QvZoKDA0OvpC5Gb6tvztLXeCdKBH lzMkJptjyqB+Ciyel6YhpAvSLTxolVloaHrLieY13RsNWjbCtX1iASzgouciXzNMVJbb C0vQk7kPcAbak6PFJiWz3trOQOraN8qxYQK/PBrfB7zx/1B4eVIsLIcAS+Q69fYieYOY vKUkH4vaT3ZhAVv9wUWPC/DK6haLs/kl4qu5bUI821SC9k/DO//uOtC/cpF/lSo5KFPZ h6LpP1LiDZvgzDQSEbgpk9Hxwa5WZHQccoxSU5hL+LcO6SVQJK4bLjqQUfn0gHoV8Buv rsCQ== X-Gm-Message-State: AOJu0Yzr9aM/FdUn3NzO0WFEjL+CcO+J8AdVAaWUZOnQIimPWMw5Mk2s 83FiVPxJe9LEr+5j+3z4Iw6unoEuaV8wvZoPQ54ti85wNLLPfpoIaVNaFanKL3GAyLlPdQ3QHLh Q5Gc= X-Google-Smtp-Source: AGHT+IH5p7dLi6RF6/Udu3gjScmM2zK87XtgN7a0APjO1Y0PLpjL8sE5paodCue1L3k4D4J+1bd66w== X-Received: by 2002:a17:902:e852:b0:1d7:41b7:332b with SMTP id t18-20020a170902e85200b001d741b7332bmr875256plg.14.1705796473556; Sat, 20 Jan 2024 16:21:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Subject: [PULL 7/8] linux-user/elfload: test return value of getrlimit Date: Sun, 21 Jan 2024 11:20:46 +1100 Message-Id: <20240121002047.89234-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121002047.89234-1-richard.henderson@linaro.org> References: <20240121002047.89234-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705796571699100003 From: Thomas Wei=C3=9Fschuh Should getrlimit() fail the value of dumpsize.rlimit_cur may not be initialized. Avoid reading garbage data by checking the return value of getrlimit. Reviewed-by: Richard Henderson Signed-off-by: Thomas Wei=C3=9Fschuh Message-Id: <20240120-qemu-user-dumpable-v3-1-6aa410c933f1@t-8ch.de> Signed-off-by: Richard Henderson --- linux-user/elfload.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index cf9e74468b..c596871938 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -4667,9 +4667,9 @@ static int elf_core_dump(int signr, const CPUArchStat= e *env) init_note_info(&info); =20 errno =3D 0; - getrlimit(RLIMIT_CORE, &dumpsize); - if (dumpsize.rlim_cur =3D=3D 0) + if (getrlimit(RLIMIT_CORE, &dumpsize) =3D=3D 0 && dumpsize.rlim_cur = =3D=3D 0) { return 0; + } =20 corefile =3D core_dump_filename(ts); =20 --=20 2.34.1 From nobody Tue Nov 26 17:27:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705796539; cv=none; d=zohomail.com; s=zohoarc; b=CpS2D2hYEP5GR6jqdSR6NeZU5DFI3TBsEEavTxVnb4zgyaTCLz8p6Lu26gr01sKUvILDajCAerpRoB6wum/2X6Z+3WOxW2paEqad/G65XyxwknNSCoRD+qhi1+Sw57rRJtfonnlvGBMDvzZvkU6L1WN2hVWTiRYfAWu3uAHQeGI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705796539; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AszAzFAp6jrF5ZpcMELuMynXb9ZnBs+nghMoHKpvVGo=; b=ng8fjrLL8OAHsrOjZ8NXnFcsbp++auD9P/ZUP5xVqY7DxSxTEZnYAhqwmguEeNapXObyftwG5RASUFDvcxFgfESmaVLUB2DEQwmmfO8hMoblCzwLDFi0EYPONOTtmtbT4cqM8D6/VSLTHqeviq6VVcQyMIWeHuwqdjzWFjG3UfM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705796539488590.1869297697331; Sat, 20 Jan 2024 16:22:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rRLaS-0002ZG-Dz; Sat, 20 Jan 2024 19:21:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rRLaQ-0002Yr-DT for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:18 -0500 Received: from mail-il1-x134.google.com ([2607:f8b0:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rRLaO-0007RM-TH for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:18 -0500 Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-361ae51a4d9so5617905ab.1 for ; Sat, 20 Jan 2024 16:21:16 -0800 (PST) Received: from stoup.net ([2001:8004:5170:1e39:1361:3840:4873:7990]) by smtp.gmail.com with ESMTPSA id j4-20020a17090276c400b001d5af7fbda0sm5023546plt.122.2024.01.20.16.21.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 16:21:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705796476; x=1706401276; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AszAzFAp6jrF5ZpcMELuMynXb9ZnBs+nghMoHKpvVGo=; b=rusVckiWhew5o9FyoD9wdQAgIw9aUm8aOym54TDh1ozMzNfdcwXeoBLZnLEJyyxrx3 vczkPgABUICoEKlNWX78cNhZz4vx15AivBIIJlwg+wFWmdgFGgLT4iK0rasZzQBOYGYB ZkQjvQZhHadzMtRSp3rJw8EPwNXaau4YBVc0UNKu7wF7yokm8n5WP3TSEXI2bZljOgLx bAz6WufDn+x3Q4PpBqoS9EnEHMIxPd9gfHqYVTRnjoUka+/oJ91UysJAeTpIyKzb9qh8 Q/DszWP0V0UAA+zJ2byhoCz6Oxmf08L8mGY5/PuSjmaabvfacxonS/WG+VmHM9npsEsh QW+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705796476; x=1706401276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AszAzFAp6jrF5ZpcMELuMynXb9ZnBs+nghMoHKpvVGo=; b=V3ERk6n/Rb4hlwrYafJTexuinREbjcxnANg1dZrx2TESrF7esLrdNe57PZcNfR6Zh1 xR4eAYhSd5AgGX7I9N+GzD46TIlSvwFCHyW09QCjzTFD1C8z2ZyEZtyUg6uVIaFkNlP9 FS7S9ucGEmThMYIS1MICFqLerZMpYW/3Bl2VcWrDh5EP55KljiQAYlE40MyTFQqrwvf7 3tlQsJVAmrOK6REt3hH7QMHARFEEBx49rXjOwQt1hc5J7m9YTL5YDOA32ms++3x0gcuu Mk6lZe6dTgka9phPhzO3Is0p3UP/1hXUUt0MvN6nNt13N7Iro6RHhjEHUJeW3GVMs4/n mrmw== X-Gm-Message-State: AOJu0YzKUHZ8kQeer9vs/RajK8byugWw/cP1Al2Mzvd6QZHcB6t/yoT5 5X0qKb3/l3y38xkRjITcHQZd/93Tc83EHU5KjJ96WKV3+2DVFaC0rkVRjbXDUPIsO3lOAJO9VZ9 mWD4= X-Google-Smtp-Source: AGHT+IG/vxkYNFSyvsgw+P6dfYaW3iC6CHH2AV4xlOjNkwmaXPLJlvs14wMWQKYehkGKhxmR8gIreg== X-Received: by 2002:a05:6e02:f14:b0:35f:ca9d:6c42 with SMTP id x20-20020a056e020f1400b0035fca9d6c42mr3071536ilj.4.1705796475892; Sat, 20 Jan 2024 16:21:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Subject: [PULL 8/8] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump Date: Sun, 21 Jan 2024 11:20:47 +1100 Message-Id: <20240121002047.89234-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121002047.89234-1-richard.henderson@linaro.org> References: <20240121002047.89234-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::134; envelope-from=richard.henderson@linaro.org; helo=mail-il1-x134.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705796542198100007 From: Thomas Wei=C3=9Fschuh A process can opt-out of coredump creation by calling prctl(PR_SET_DUMPABLE, 0). linux-user passes this call from the guest through to the operating system. From there it can be read back again to avoid creating coredumps from qemu-user itself if the guest chose so. Reviewed-by: Richard Henderson Signed-off-by: Thomas Wei=C3=9Fschuh Message-Id: <20240120-qemu-user-dumpable-v3-2-6aa410c933f1@t-8ch.de> Signed-off-by: Richard Henderson --- linux-user/elfload.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index c596871938..daf7ef8435 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2,6 +2,7 @@ #include "qemu/osdep.h" #include =20 +#include #include #include =20 @@ -4667,6 +4668,11 @@ static int elf_core_dump(int signr, const CPUArchSta= te *env) init_note_info(&info); =20 errno =3D 0; + + if (prctl(PR_GET_DUMPABLE) =3D=3D 0) { + return 0; + } + if (getrlimit(RLIMIT_CORE, &dumpsize) =3D=3D 0 && dumpsize.rlim_cur = =3D=3D 0) { return 0; } --=20 2.34.1