From patchwork Sun Jul 9 18:28:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700852 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827095wrs; Sun, 9 Jul 2023 11:31:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlHlKo8ke+qi8ARVTGYFfa2ENUkXf5VBM9vo49KfGmbWBUzSmAo79+eXuHwVkxb68D9q7Bew X-Received: by 2002:a05:620a:e99:b0:766:e430:21b8 with SMTP id w25-20020a05620a0e9900b00766e43021b8mr7823956qkm.75.1688927465560; Sun, 09 Jul 2023 11:31:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927465; cv=none; d=google.com; s=arc-20160816; b=gJGx+bMtbx/7zLps27oaivJDn8lzPEkvH0pkBc7enEZpksOF892IfXNlbhpp4FMgvz cwo2aVo6dIDjsXy+il2+bQQRGswMMDh366liQxfhWgS9DmvOMufisbPma7LsLETCbKBv qqEdRIsTQbG3Fx/X4ZeVfdGH7gbuMao5Ah6UKS0kQzhF2bKmALGeFTDkIVm2kLQ045ub StJrropspXs/YVpYtb5GkqIOUJdsQ61SSmr1KjcEKYtSk4/7cmAHP0QF4V/r+Ta7zwxE UNhGS6RBe4ocE4iayCFgRlyfqrvrPZ1893QYFgyOQ935JIq85uC4AyKRvewmo0vxyxtp OxRA== 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:cc:to :from:dkim-signature; bh=KMA70dMb1SJ/eTe/2+zO5JW0aBcXeIGHYSkfDyZwFgY=; fh=vt5PnLhDoDj0CK6sQmjgOuq7ZR8IvVqHabl0gLsltKk=; b=AEYRP/rmb0dmupHT9dfMVxfSz0BJS5rJV3zzDzueVDKxl/cYWK8O1+Ff1WvhIIX1T8 aAMtveLlHAHY5XyZ+Q0aKFzwbDAQtsj0vQ+mSHjkj6IPwYJuwz+DwziyZMJ7NarSoVmo uFyve95+qGxRrT52RaJTU376xCRhLT/LCLyxxm5ljgdjEgK+j5dN1knHcmoZnwlu8TjC /EmwHydIg9OJ6mBLjDJrbHewJEHQ724R9sOsEP9RgcJ9KVanRk3z43Iqj0DdMlK82kSG yAaOy/PD/2Sl82IG/bmR+Hf399Bj70NpWLquS2fXAlruA1qBK1cce39t/kU+DuoPDK+W ksYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qBVPJ2Mn; 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 qr18-20020a05620a391200b00767d0cb5098si505279qkn.438.2023.07.09.11.31.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:31:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qBVPJ2Mn; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAQ-0008Go-R8; Sun, 09 Jul 2023 14:29:54 -0400 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 1qIZAI-0008Dg-1b for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:46 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAE-0000DT-DO for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:45 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fbea147034so37211135e9.0 for ; Sun, 09 Jul 2023 11:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927378; x=1691519378; 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=KMA70dMb1SJ/eTe/2+zO5JW0aBcXeIGHYSkfDyZwFgY=; b=qBVPJ2MnRNSW4BqnYe+HeO6n6IxtwRo3NqXuUSgPWQNNFhNFrEXqE5GweGQLqJKB/+ ZjmQDSU7V6vPNXNd2q29l7K96aIdQGYx5wIxCd5qJqmaYFigkm/XoMHnP2uaZy/kYs9F tCmU8Em8Cks4d2qWjuyf/75kU+xgCKqj8gH8rqBlXbtkbd/JSfHwELrtnKAgAUb9FcYe zl333+aPIp2MuTQAZHhNVtv59vfkpvTbiHBUvU8CF8hMfZDsUfAJqrrRjGDaIgveorO/ wAshQS99G/rNI+K6MUsHF4lz+qqfHcsW+Njns83/XNG3AM4Qbk0GXSl0AuzORAVclLFv KqnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927378; x=1691519378; 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=KMA70dMb1SJ/eTe/2+zO5JW0aBcXeIGHYSkfDyZwFgY=; b=MkrGHwcBNi8K0fdKXh6UI2buL5g4JhJm7toXA3Uo0tcFv9MBxxdmmBMO7sKjIffpuf NyJgGx/OLahO6hpRhJesaWXV0dJW1T/BQ+ZqtEz3tY+7QAqw9zMjiCf9nHM9CckZikrQ hqcMkwmc08U2+lgnI//LAxb1L9YmS5qHIknx4kxWQtGnqTFCIkh+bKdUaC4ctg4XMliM 6yD28u4tmGWtpH0a6XW7CPd2sa2/w5Phfr2AaDVUZDpWeQT04kQ/zTNBfdXliVHfRne6 GGULNioIYloGOp3H5rVLDCXEto6YxqRGeHggkVgivCeNTK8qPNH3xsgPTMvMJNl+hzoW bP9w== X-Gm-Message-State: ABy/qLadFzZnRkAWiCHoJKex33ioqyvQvOY2nxfBpecs2Aj1SJtwrVXe TEBZsL5C/j8oy02oJIZ9TzB9YA/gs1aKess9nYYZLQ== X-Received: by 2002:a1c:730b:0:b0:3fb:c384:89ef with SMTP id d11-20020a1c730b000000b003fbc38489efmr8136991wmb.17.1688927378392; Sun, 09 Jul 2023 11:29:38 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.29.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:29:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Daniel Henrique Barboza Subject: [PULL 01/37] util: Add cpuinfo-ppc.c Date: Sun, 9 Jul 2023 19:28:14 +0100 Message-Id: <20230709182934.309468-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x331.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Move the code from tcg/. Fix a bug in that PPC_FEATURE2_ARCH_3_10 is actually spelled PPC_FEATURE2_ARCH_3_1. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- host/include/ppc/host/cpuinfo.h | 29 ++++++++++++++++ host/include/ppc64/host/cpuinfo.h | 1 + tcg/ppc/tcg-target.h | 16 ++++----- util/cpuinfo-ppc.c | 56 +++++++++++++++++++++++++++++++ tcg/ppc/tcg-target.c.inc | 44 +----------------------- util/meson.build | 2 ++ 6 files changed, 97 insertions(+), 51 deletions(-) create mode 100644 host/include/ppc/host/cpuinfo.h create mode 100644 host/include/ppc64/host/cpuinfo.h create mode 100644 util/cpuinfo-ppc.c diff --git a/host/include/ppc/host/cpuinfo.h b/host/include/ppc/host/cpuinfo.h new file mode 100644 index 0000000000..df11e8d417 --- /dev/null +++ b/host/include/ppc/host/cpuinfo.h @@ -0,0 +1,29 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * Host specific cpu indentification for ppc. + */ + +#ifndef HOST_CPUINFO_H +#define HOST_CPUINFO_H + +/* Digested version of */ + +#define CPUINFO_ALWAYS (1u << 0) /* so cpuinfo is nonzero */ +#define CPUINFO_V2_06 (1u << 1) +#define CPUINFO_V2_07 (1u << 2) +#define CPUINFO_V3_0 (1u << 3) +#define CPUINFO_V3_1 (1u << 4) +#define CPUINFO_ISEL (1u << 5) +#define CPUINFO_ALTIVEC (1u << 6) +#define CPUINFO_VSX (1u << 7) + +/* Initialized with a constructor. */ +extern unsigned cpuinfo; + +/* + * We cannot rely on constructor ordering, so other constructors must + * use the function interface rather than the variable above. + */ +unsigned cpuinfo_init(void); + +#endif /* HOST_CPUINFO_H */ diff --git a/host/include/ppc64/host/cpuinfo.h b/host/include/ppc64/host/cpuinfo.h new file mode 100644 index 0000000000..2f036a0627 --- /dev/null +++ b/host/include/ppc64/host/cpuinfo.h @@ -0,0 +1 @@ +#include "host/include/ppc/host/cpuinfo.h" diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index c7552b6391..9a41fab8cc 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -25,6 +25,8 @@ #ifndef PPC_TCG_TARGET_H #define PPC_TCG_TARGET_H +#include "host/cpuinfo.h" + #define MAX_CODE_GEN_BUFFER_SIZE ((size_t)-1) #define TCG_TARGET_NB_REGS 64 @@ -61,14 +63,12 @@ typedef enum { tcg_isa_3_10, } TCGPowerISA; -extern TCGPowerISA have_isa; -extern bool have_altivec; -extern bool have_vsx; - -#define have_isa_2_06 (have_isa >= tcg_isa_2_06) -#define have_isa_2_07 (have_isa >= tcg_isa_2_07) -#define have_isa_3_00 (have_isa >= tcg_isa_3_00) -#define have_isa_3_10 (have_isa >= tcg_isa_3_10) +#define have_isa_2_06 (cpuinfo & CPUINFO_V2_06) +#define have_isa_2_07 (cpuinfo & CPUINFO_V2_07) +#define have_isa_3_00 (cpuinfo & CPUINFO_V3_0) +#define have_isa_3_10 (cpuinfo & CPUINFO_V3_1) +#define have_altivec (cpuinfo & CPUINFO_ALTIVEC) +#define have_vsx (cpuinfo & CPUINFO_VSX) /* optional instructions automatically implemented */ #define TCG_TARGET_HAS_ext8u_i32 0 /* andi */ diff --git a/util/cpuinfo-ppc.c b/util/cpuinfo-ppc.c new file mode 100644 index 0000000000..d95adc8ccd --- /dev/null +++ b/util/cpuinfo-ppc.c @@ -0,0 +1,56 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * Host specific cpu indentification for ppc. + */ + +#include "qemu/osdep.h" +#include "host/cpuinfo.h" + +#ifdef CONFIG_GETAUXVAL +# include +#else +# include +# include "elf.h" +#endif + +unsigned cpuinfo; + +/* Called both as constructor and (possibly) via other constructors. */ +unsigned __attribute__((constructor)) cpuinfo_init(void) +{ + unsigned info = cpuinfo; + unsigned long hwcap, hwcap2; + + if (info) { + return info; + } + + hwcap = qemu_getauxval(AT_HWCAP); + hwcap2 = qemu_getauxval(AT_HWCAP2); + info = CPUINFO_ALWAYS; + + /* Version numbers are monotonic, and so imply all lower versions. */ + if (hwcap2 & PPC_FEATURE2_ARCH_3_1) { + info |= CPUINFO_V3_1 | CPUINFO_V3_0 | CPUINFO_V2_07 | CPUINFO_V2_06; + } else if (hwcap2 & PPC_FEATURE2_ARCH_3_00) { + info |= CPUINFO_V3_0 | CPUINFO_V2_07 | CPUINFO_V2_06; + } else if (hwcap2 & PPC_FEATURE2_ARCH_2_07) { + info |= CPUINFO_V2_07 | CPUINFO_V2_06; + } else if (hwcap & PPC_FEATURE_ARCH_2_06) { + info |= CPUINFO_V2_06; + } + + if (hwcap2 & PPC_FEATURE2_HAS_ISEL) { + info |= CPUINFO_ISEL; + } + if (hwcap & PPC_FEATURE_HAS_ALTIVEC) { + info |= CPUINFO_ALTIVEC; + /* We only care about the portion of VSX that overlaps Altivec. */ + if (hwcap & PPC_FEATURE_HAS_VSX) { + info |= CPUINFO_VSX; + } + } + + cpuinfo = info; + return info; +} diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 5c8378f8f6..c866f2c997 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -101,10 +101,7 @@ #define ALL_GENERAL_REGS 0xffffffffu #define ALL_VECTOR_REGS 0xffffffff00000000ull -TCGPowerISA have_isa; -static bool have_isel; -bool have_altivec; -bool have_vsx; +#define have_isel (cpuinfo & CPUINFO_ISEL) #ifndef CONFIG_SOFTMMU #define TCG_GUEST_BASE_REG 30 @@ -3879,45 +3876,6 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) static void tcg_target_init(TCGContext *s) { - unsigned long hwcap = qemu_getauxval(AT_HWCAP); - unsigned long hwcap2 = qemu_getauxval(AT_HWCAP2); - - have_isa = tcg_isa_base; - if (hwcap & PPC_FEATURE_ARCH_2_06) { - have_isa = tcg_isa_2_06; - } -#ifdef PPC_FEATURE2_ARCH_2_07 - if (hwcap2 & PPC_FEATURE2_ARCH_2_07) { - have_isa = tcg_isa_2_07; - } -#endif -#ifdef PPC_FEATURE2_ARCH_3_00 - if (hwcap2 & PPC_FEATURE2_ARCH_3_00) { - have_isa = tcg_isa_3_00; - } -#endif -#ifdef PPC_FEATURE2_ARCH_3_10 - if (hwcap2 & PPC_FEATURE2_ARCH_3_10) { - have_isa = tcg_isa_3_10; - } -#endif - -#ifdef PPC_FEATURE2_HAS_ISEL - /* Prefer explicit instruction from the kernel. */ - have_isel = (hwcap2 & PPC_FEATURE2_HAS_ISEL) != 0; -#else - /* Fall back to knowing Power7 (2.06) has ISEL. */ - have_isel = have_isa_2_06; -#endif - - if (hwcap & PPC_FEATURE_HAS_ALTIVEC) { - have_altivec = true; - /* We only care about the portion of VSX that overlaps Altivec. */ - if (hwcap & PPC_FEATURE_HAS_VSX) { - have_vsx = true; - } - } - tcg_target_available_regs[TCG_TYPE_I32] = 0xffffffff; tcg_target_available_regs[TCG_TYPE_I64] = 0xffffffff; if (have_altivec) { diff --git a/util/meson.build b/util/meson.build index 3a93071d27..a375160286 100644 --- a/util/meson.build +++ b/util/meson.build @@ -113,4 +113,6 @@ if cpu == 'aarch64' util_ss.add(files('cpuinfo-aarch64.c')) elif cpu in ['x86', 'x86_64'] util_ss.add(files('cpuinfo-i386.c')) +elif cpu in ['ppc', 'ppc64'] + util_ss.add(files('cpuinfo-ppc.c')) endif From patchwork Sun Jul 9 18:28:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700860 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827408wrs; Sun, 9 Jul 2023 11:32:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlEolMC9RnkYyYovcpQl3hhmLgbuELfY6aRfIqytalZCnSBwhFswpTZxcGqK/yC1TBOJvQJV X-Received: by 2002:ac8:5b88:0:b0:402:3dbf:85fb with SMTP id a8-20020ac85b88000000b004023dbf85fbmr16841877qta.33.1688927529572; Sun, 09 Jul 2023 11:32:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927529; cv=none; d=google.com; s=arc-20160816; b=Gr0NFboC+IXhcvesTDSoVGCI90hV2VvGgTmcHiEneXlFVauFcPB8+uDubH+k7L+kpK /9ilehzHEpBULURQQaxjwYbiM6b8kQOPPDxFrmMW90Rdl3gJ1jfKmDa/Tb/oT9JKHn1W sxThag+XI7Mq5RtdZEXCFQtQsCGQEQMPxO1Q95ABlNxdTeShP78W2cHgALtCYJDYUgTk uyRU4YW+6jiYbibk5YMvS9RjIbFBthSvm/5GibFGid5p+JGnK42oM+rfKt9D/wP8Pah4 7UEklEbvcv7coc122Nu07oMoDMDN2xAbDYJljqmrYNlrSpzty4BFv8hdiopYR0F3DdSZ JoMA== 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:cc:to :from:dkim-signature; bh=PHrPJPS+mlRVkDvCLAEYdPQN/uxz8IaF+SaQf2EtYVY=; fh=Q/KtKvobZ4aKW4dKNmZSl6eueXWWlvOAYdnlEZxfDJk=; b=stHKh6pgNA0n/NQ0Icifu0PTywqfq2MCPUtSu73YpCAN3SDB3mN1C3QIEOxnAr77DG JgxxvjXzO2/JunzYH1F/NZwg34gUgpcfegdc14euGDFfeQIF60gc3NSA3q2UiyvVQcaJ jn9GL+bHcp46kBo/87L/igwhB72zsAMMi272xBfo7252/si80gpQykkz/8qePVAcKJTf wB80dyIrOodZj8FhjjdLqXHB9+WnF3q28l/+jqafpYZhk4mnufAFqyZXvfCQspCi4lcr lsWouoE/oXZZ/0D7MYPI7PXZaGLVN52rMQPVqsJ1pCZP4ldB8YoPA4VJT1uC2aMLDy2H JbVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bgzpLL7B; 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 s12-20020ac85ccc000000b00403a049c5fdsi2537452qta.396.2023.07.09.11.32.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:32:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bgzpLL7B; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAQ-0008Gg-IL; Sun, 09 Jul 2023 14:29:54 -0400 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 1qIZAI-0008E4-Qw for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:48 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAE-0000Dm-CR for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:46 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fbc244d384so38080605e9.0 for ; Sun, 09 Jul 2023 11:29:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927380; x=1691519380; 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=PHrPJPS+mlRVkDvCLAEYdPQN/uxz8IaF+SaQf2EtYVY=; b=bgzpLL7B7STqInrIzATJhAlMdqyW4Oyvw2wzg4kr9wqNzfmetoiwCVoVx1/Jh9eiak fHgDY77nj77mgrN2O8GaBl1tPSGySKsZK5VyGju3fQstXZepxlHUcL13Pm9O/oaeEQEW wZ85XklPURb45cvgXOm8JVwSPCYbPF54X9XQT3J3jOE8XaVHbHGwWs9IkldVBjOQQUPk BcPiMpYOQkfo7a4EN6zTPINuRaA5seU44tbMoFsNEXwK5h+ECHsylpWV0FzoA+7LccG7 8soQzIQ7r+dSjD5QVcvyHR0aEvE/W5IFpRa+jNvT4eHO7c6OfX6Bi55CG6uFokgnmSlK L7DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927380; x=1691519380; 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=PHrPJPS+mlRVkDvCLAEYdPQN/uxz8IaF+SaQf2EtYVY=; b=NbwVIbR2dMglTgj6euQLINoVGhRa6fOTKPRhSa4rGwwXp7IKxW0jKFkhk6XLD1egbk KIKiVd2Y4U8H5FTJlhHgpJoqpirXUj8FjAB8McxXIJV8JYmCQR9eCrGhrIn7fHML01tp Spy+6cDhgyYO2N30EWdhAQa1V2aWfXsUT7bb3b9WXkPW6S/+JMZRpOTVabKLs7RhQcUn B2q4Eefko/FAfInBH/00AtgpNTk+XAvsoxDvRC+pUApBilO/PV9KSaYReg5UaOxirOaw o8nzUGmoZjUOSjWK79m8H/K/ba52hiVKk4epLu9OhrxYIOXiqIO2/gEtlrgmu8IqBsN+ 7beg== X-Gm-Message-State: ABy/qLbCY49ccExaNsRC6/OzpgSEKLaC1GA2SRwCtw0dFj45apZILZEl Nu5M2XzQ7fD5qZAWWzDYZLs6ToCO0OoQ5RnpSlR88g== X-Received: by 2002:a05:600c:ad8:b0:3fb:fa61:a4ed with SMTP id c24-20020a05600c0ad800b003fbfa61a4edmr6154799wmr.26.1688927379960; Sun, 09 Jul 2023 11:29:39 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.29.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:29:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 02/37] tests/multiarch: Add test-aes Date: Sun, 9 Jul 2023 19:28:16 +0100 Message-Id: <20230709182934.309468-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32c.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use a shared driver and backends for i386, aarch64, ppc64, riscv64. Acked-by: Alex Bennée Signed-off-by: Richard Henderson --- tests/tcg/aarch64/test-aes.c | 58 ++++++++ tests/tcg/i386/test-aes.c | 68 +++++++++ tests/tcg/ppc64/test-aes.c | 116 +++++++++++++++ tests/tcg/riscv64/test-aes.c | 81 +++++++++++ tests/tcg/multiarch/test-aes-main.c.inc | 183 ++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 4 + tests/tcg/i386/Makefile.target | 4 + tests/tcg/ppc64/Makefile.target | 1 + tests/tcg/riscv64/Makefile.target | 3 + 9 files changed, 518 insertions(+) create mode 100644 tests/tcg/aarch64/test-aes.c create mode 100644 tests/tcg/i386/test-aes.c create mode 100644 tests/tcg/ppc64/test-aes.c create mode 100644 tests/tcg/riscv64/test-aes.c create mode 100644 tests/tcg/multiarch/test-aes-main.c.inc diff --git a/tests/tcg/aarch64/test-aes.c b/tests/tcg/aarch64/test-aes.c new file mode 100644 index 0000000000..2cd324f09b --- /dev/null +++ b/tests/tcg/aarch64/test-aes.c @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "../multiarch/test-aes-main.c.inc" + +bool test_SB_SR(uint8_t *o, const uint8_t *i) +{ + /* aese also adds round key, so supply zero. */ + asm("ld1 { v0.16b }, [%1]\n\t" + "movi v1.16b, #0\n\t" + "aese v0.16b, v1.16b\n\t" + "st1 { v0.16b }, [%0]" + : : "r"(o), "r"(i) : "v0", "v1", "memory"); + return true; +} + +bool test_MC(uint8_t *o, const uint8_t *i) +{ + asm("ld1 { v0.16b }, [%1]\n\t" + "aesmc v0.16b, v0.16b\n\t" + "st1 { v0.16b }, [%0]" + : : "r"(o), "r"(i) : "v0", "memory"); + return true; +} + +bool test_SB_SR_MC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + return false; +} + +bool test_ISB_ISR(uint8_t *o, const uint8_t *i) +{ + /* aesd also adds round key, so supply zero. */ + asm("ld1 { v0.16b }, [%1]\n\t" + "movi v1.16b, #0\n\t" + "aesd v0.16b, v1.16b\n\t" + "st1 { v0.16b }, [%0]" + : : "r"(o), "r"(i) : "v0", "v1", "memory"); + return true; +} + +bool test_IMC(uint8_t *o, const uint8_t *i) +{ + asm("ld1 { v0.16b }, [%1]\n\t" + "aesimc v0.16b, v0.16b\n\t" + "st1 { v0.16b }, [%0]" + : : "r"(o), "r"(i) : "v0", "memory"); + return true; +} + +bool test_ISB_ISR_AK_IMC(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + return false; +} + +bool test_ISB_ISR_IMC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + return false; +} diff --git a/tests/tcg/i386/test-aes.c b/tests/tcg/i386/test-aes.c new file mode 100644 index 0000000000..199395e6cc --- /dev/null +++ b/tests/tcg/i386/test-aes.c @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "../multiarch/test-aes-main.c.inc" +#include + +static bool test_SB_SR(uint8_t *o, const uint8_t *i) +{ + __m128i vi = _mm_loadu_si128((const __m128i_u *)i); + + /* aesenclast also adds round key, so supply zero. */ + vi = _mm_aesenclast_si128(vi, _mm_setzero_si128()); + + _mm_storeu_si128((__m128i_u *)o, vi); + return true; +} + +static bool test_MC(uint8_t *o, const uint8_t *i) +{ + return false; +} + +static bool test_SB_SR_MC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + __m128i vi = _mm_loadu_si128((const __m128i_u *)i); + __m128i vk = _mm_loadu_si128((const __m128i_u *)k); + + vi = _mm_aesenc_si128(vi, vk); + + _mm_storeu_si128((__m128i_u *)o, vi); + return true; +} + +static bool test_ISB_ISR(uint8_t *o, const uint8_t *i) +{ + __m128i vi = _mm_loadu_si128((const __m128i_u *)i); + + /* aesdeclast also adds round key, so supply zero. */ + vi = _mm_aesdeclast_si128(vi, _mm_setzero_si128()); + + _mm_storeu_si128((__m128i_u *)o, vi); + return true; +} + +static bool test_IMC(uint8_t *o, const uint8_t *i) +{ + __m128i vi = _mm_loadu_si128((const __m128i_u *)i); + + vi = _mm_aesimc_si128(vi); + + _mm_storeu_si128((__m128i_u *)o, vi); + return true; +} + +static bool test_ISB_ISR_AK_IMC(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + return false; +} + +static bool test_ISB_ISR_IMC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + __m128i vi = _mm_loadu_si128((const __m128i_u *)i); + __m128i vk = _mm_loadu_si128((const __m128i_u *)k); + + vi = _mm_aesdec_si128(vi, vk); + + _mm_storeu_si128((__m128i_u *)o, vi); + return true; +} diff --git a/tests/tcg/ppc64/test-aes.c b/tests/tcg/ppc64/test-aes.c new file mode 100644 index 0000000000..1d2be488e9 --- /dev/null +++ b/tests/tcg/ppc64/test-aes.c @@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "../multiarch/test-aes-main.c.inc" + +#undef BIG_ENDIAN +#define BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) + +static unsigned char bswap_le[16] __attribute__((aligned(16))) = { + 8,9,10,11,12,13,14,15, + 0,1,2,3,4,5,6,7 +}; + +bool test_SB_SR(uint8_t *o, const uint8_t *i) +{ + /* vcipherlast also adds round key, so supply zero. */ + if (BIG_ENDIAN) { + asm("lxvd2x 32,0,%1\n\t" + "vspltisb 1,0\n\t" + "vcipherlast 0,0,1\n\t" + "stxvd2x 32,0,%0" + : : "r"(o), "r"(i) : "memory", "v0", "v1"); + } else { + asm("lxvd2x 32,0,%1\n\t" + "lxvd2x 34,0,%2\n\t" + "vspltisb 1,0\n\t" + "vperm 0,0,0,2\n\t" + "vcipherlast 0,0,1\n\t" + "vperm 0,0,0,2\n\t" + "stxvd2x 32,0,%0" + : : "r"(o), "r"(i), "r"(bswap_le) : "memory", "v0", "v1", "v2"); + } + return true; +} + +bool test_MC(uint8_t *o, const uint8_t *i) +{ + return false; +} + +bool test_SB_SR_MC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + if (BIG_ENDIAN) { + asm("lxvd2x 32,0,%1\n\t" + "lxvd2x 33,0,%2\n\t" + "vcipher 0,0,1\n\t" + "stxvd2x 32,0,%0" + : : "r"(o), "r"(i), "r"(k) : "memory", "v0", "v1"); + } else { + asm("lxvd2x 32,0,%1\n\t" + "lxvd2x 33,0,%2\n\t" + "lxvd2x 34,0,%3\n\t" + "vperm 0,0,0,2\n\t" + "vperm 1,1,1,2\n\t" + "vcipher 0,0,1\n\t" + "vperm 0,0,0,2\n\t" + "stxvd2x 32,0,%0" + : : "r"(o), "r"(i), "r"(k), "r"(bswap_le) + : "memory", "v0", "v1", "v2"); + } + return true; +} + +bool test_ISB_ISR(uint8_t *o, const uint8_t *i) +{ + /* vcipherlast also adds round key, so supply zero. */ + if (BIG_ENDIAN) { + asm("lxvd2x 32,0,%1\n\t" + "vspltisb 1,0\n\t" + "vncipherlast 0,0,1\n\t" + "stxvd2x 32,0,%0" + : : "r"(o), "r"(i) : "memory", "v0", "v1"); + } else { + asm("lxvd2x 32,0,%1\n\t" + "lxvd2x 34,0,%2\n\t" + "vspltisb 1,0\n\t" + "vperm 0,0,0,2\n\t" + "vncipherlast 0,0,1\n\t" + "vperm 0,0,0,2\n\t" + "stxvd2x 32,0,%0" + : : "r"(o), "r"(i), "r"(bswap_le) : "memory", "v0", "v1", "v2"); + } + return true; +} + +bool test_IMC(uint8_t *o, const uint8_t *i) +{ + return false; +} + +bool test_ISB_ISR_AK_IMC(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + if (BIG_ENDIAN) { + asm("lxvd2x 32,0,%1\n\t" + "lxvd2x 33,0,%2\n\t" + "vncipher 0,0,1\n\t" + "stxvd2x 32,0,%0" + : : "r"(o), "r"(i), "r"(k) : "memory", "v0", "v1"); + } else { + asm("lxvd2x 32,0,%1\n\t" + "lxvd2x 33,0,%2\n\t" + "lxvd2x 34,0,%3\n\t" + "vperm 0,0,0,2\n\t" + "vperm 1,1,1,2\n\t" + "vncipher 0,0,1\n\t" + "vperm 0,0,0,2\n\t" + "stxvd2x 32,0,%0" + : : "r"(o), "r"(i), "r"(k), "r"(bswap_le) + : "memory", "v0", "v1", "v2"); + } + return true; +} + +bool test_ISB_ISR_IMC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + return false; +} diff --git a/tests/tcg/riscv64/test-aes.c b/tests/tcg/riscv64/test-aes.c new file mode 100644 index 0000000000..6a0ef77e7b --- /dev/null +++ b/tests/tcg/riscv64/test-aes.c @@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "../multiarch/test-aes-main.c.inc" + +bool test_SB_SR(uint8_t *o, const uint8_t *i) +{ + uint64_t *o8 = (uint64_t *)o; + const uint64_t *i8 = (const uint64_t *)i; + + /* aes64es rd, rs1, rs2 = 0011001 rs2 rs1 000 rd 0110011 */ + asm(".insn r 0x33, 0x0, 0x19, %0, %2, %3\n\t" + ".insn r 0x33, 0x0, 0x19, %1, %3, %2" + : "=&r"(o8[0]), "=&r"(o8[1]) : "r"(i8[0]), "r"(i8[1])); + return true; +} + +bool test_MC(uint8_t *o, const uint8_t *i) +{ + return false; +} + +bool test_SB_SR_MC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + uint64_t *o8 = (uint64_t *)o; + const uint64_t *i8 = (const uint64_t *)i; + const uint64_t *k8 = (const uint64_t *)k; + + /* aesesm rd, rs1, rs2 = 0011011 rs2 rs1 000 rd 0110011 */ + asm(".insn r 0x33, 0x0, 0x1b, %0, %2, %3\n\t" + ".insn r 0x33, 0x0, 0x1b, %1, %3, %2\n\t" + "xor %0,%0,%4\n\t" + "xor %1,%1,%5" + : "=&r"(o8[0]), "=&r"(o8[1]) + : "r"(i8[0]), "r"(i8[1]), "r"(k8[0]), "r"(k8[1])); + return true; +} + +bool test_ISB_ISR(uint8_t *o, const uint8_t *i) +{ + uint64_t *o8 = (uint64_t *)o; + const uint64_t *i8 = (const uint64_t *)i; + + /* aes64ds rd, rs1, rs2 = 0011101 rs2 rs1 000 rd 0110011 */ + asm(".insn r 0x33, 0x0, 0x1d, %0, %2, %3\n\t" + ".insn r 0x33, 0x0, 0x1d, %1, %3, %2" + : "=&r"(o8[0]), "=&r"(o8[1]) : "r"(i8[0]), "r"(i8[1])); + return true; +} + +bool test_IMC(uint8_t *o, const uint8_t *i) +{ + uint64_t *o8 = (uint64_t *)o; + const uint64_t *i8 = (const uint64_t *)i; + + /* aes64im rd, rs1 = 0011000 00000 rs1 001 rd 0010011 */ + asm(".insn r 0x13, 0x1, 0x18, %0, %0, x0\n\t" + ".insn r 0x13, 0x1, 0x18, %1, %1, x0" + : "=r"(o8[0]), "=r"(o8[1]) : "0"(i8[0]), "1"(i8[1])); + return true; +} + +bool test_ISB_ISR_AK_IMC(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + return false; +} + +bool test_ISB_ISR_IMC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k) +{ + uint64_t *o8 = (uint64_t *)o; + const uint64_t *i8 = (const uint64_t *)i; + const uint64_t *k8 = (const uint64_t *)k; + + /* aes64dsm rd, rs1, rs2 = 0011111 rs2 rs1 000 rd 0110011 */ + asm(".insn r 0x33, 0x0, 0x1f, %0, %2, %3\n\t" + ".insn r 0x33, 0x0, 0x1f, %1, %3, %2\n\t" + "xor %0,%0,%4\n\t" + "xor %1,%1,%5" + : "=&r"(o8[0]), "=&r"(o8[1]) + : "r"(i8[0]), "r"(i8[1]), "r"(k8[0]), "r"(k8[1])); + return true; +} diff --git a/tests/tcg/multiarch/test-aes-main.c.inc b/tests/tcg/multiarch/test-aes-main.c.inc new file mode 100644 index 0000000000..4b5f7f98aa --- /dev/null +++ b/tests/tcg/multiarch/test-aes-main.c.inc @@ -0,0 +1,183 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include +#include + +static bool test_SB_SR(uint8_t *o, const uint8_t *i); +static bool test_MC(uint8_t *o, const uint8_t *i); +static bool test_SB_SR_MC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k); + +static bool test_ISB_ISR(uint8_t *o, const uint8_t *i); +static bool test_IMC(uint8_t *o, const uint8_t *i); +static bool test_ISB_ISR_AK_IMC(uint8_t *o, const uint8_t *i, const uint8_t *k); +static bool test_ISB_ISR_IMC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k); + +/* + * From https://doi.org/10.6028/NIST.FIPS.197-upd1, + * Appendix B -- Cipher Example + * + * Note that the formatting of the 4x4 matrices in the document is + * column-major, whereas C is row-major. Therefore to get the bytes + * in the same order as the text, the matrices are transposed. + * + * Note that we are not going to test SubBytes or ShiftRows separately, + * so the "After SubBytes" column is omitted, using only the combined + * result "After ShiftRows" column. + */ + +/* Ease the inline assembly by aligning everything. */ +typedef struct { + uint8_t b[16] __attribute__((aligned(16))); +} State; + +typedef struct { + State start, after_sr, after_mc, round_key; +} Round; + +static const Round rounds[] = { + /* Round 1 */ + { { { 0x19, 0x3d, 0xe3, 0xbe, /* start */ + 0xa0, 0xf4, 0xe2, 0x2b, + 0x9a, 0xc6, 0x8d, 0x2a, + 0xe9, 0xf8, 0x48, 0x08, } }, + + { { 0xd4, 0xbf, 0x5d, 0x30, /* after shiftrows */ + 0xe0, 0xb4, 0x52, 0xae, + 0xb8, 0x41, 0x11, 0xf1, + 0x1e, 0x27, 0x98, 0xe5, } }, + + { { 0x04, 0x66, 0x81, 0xe5, /* after mixcolumns */ + 0xe0, 0xcb, 0x19, 0x9a, + 0x48, 0xf8, 0xd3, 0x7a, + 0x28, 0x06, 0x26, 0x4c, } }, + + { { 0xa0, 0xfa, 0xfe, 0x17, /* round key */ + 0x88, 0x54, 0x2c, 0xb1, + 0x23, 0xa3, 0x39, 0x39, + 0x2a, 0x6c, 0x76, 0x05, } } }, + + /* Round 2 */ + { { { 0xa4, 0x9c, 0x7f, 0xf2, /* start */ + 0x68, 0x9f, 0x35, 0x2b, + 0x6b, 0x5b, 0xea, 0x43, + 0x02, 0x6a, 0x50, 0x49, } }, + + { { 0x49, 0xdb, 0x87, 0x3b, /* after shiftrows */ + 0x45, 0x39, 0x53, 0x89, + 0x7f, 0x02, 0xd2, 0xf1, + 0x77, 0xde, 0x96, 0x1a, } }, + + { { 0x58, 0x4d, 0xca, 0xf1, /* after mixcolumns */ + 0x1b, 0x4b, 0x5a, 0xac, + 0xdb, 0xe7, 0xca, 0xa8, + 0x1b, 0x6b, 0xb0, 0xe5, } }, + + { { 0xf2, 0xc2, 0x95, 0xf2, /* round key */ + 0x7a, 0x96, 0xb9, 0x43, + 0x59, 0x35, 0x80, 0x7a, + 0x73, 0x59, 0xf6, 0x7f, } } }, + + /* Round 3 */ + { { { 0xaa, 0x8f, 0x5f, 0x03, /* start */ + 0x61, 0xdd, 0xe3, 0xef, + 0x82, 0xd2, 0x4a, 0xd2, + 0x68, 0x32, 0x46, 0x9a, } }, + + { { 0xac, 0xc1, 0xd6, 0xb8, /* after shiftrows */ + 0xef, 0xb5, 0x5a, 0x7b, + 0x13, 0x23, 0xcf, 0xdf, + 0x45, 0x73, 0x11, 0xb5, } }, + + { { 0x75, 0xec, 0x09, 0x93, /* after mixcolumns */ + 0x20, 0x0b, 0x63, 0x33, + 0x53, 0xc0, 0xcf, 0x7c, + 0xbb, 0x25, 0xd0, 0xdc, } }, + + { { 0x3d, 0x80, 0x47, 0x7d, /* round key */ + 0x47, 0x16, 0xfe, 0x3e, + 0x1e, 0x23, 0x7e, 0x44, + 0x6d, 0x7a, 0x88, 0x3b, } } }, +}; + +static void verify_log(const char *prefix, const State *s) +{ + printf("%s:", prefix); + for (int i = 0; i < sizeof(State); ++i) { + printf(" %02x", s->b[i]); + } + printf("\n"); +} + +static void verify(const State *ref, const State *tst, const char *which) +{ + if (!memcmp(ref, tst, sizeof(State))) { + return; + } + + printf("Mismatch on %s\n", which); + verify_log("ref", ref); + verify_log("tst", tst); + exit(EXIT_FAILURE); +} + +int main() +{ + int i, n = sizeof(rounds) / sizeof(Round); + State t; + + for (i = 0; i < n; ++i) { + if (test_SB_SR(t.b, rounds[i].start.b)) { + verify(&rounds[i].after_sr, &t, "SB+SR"); + } + } + + for (i = 0; i < n; ++i) { + if (test_MC(t.b, rounds[i].after_sr.b)) { + verify(&rounds[i].after_mc, &t, "MC"); + } + } + + /* The kernel of Cipher(). */ + for (i = 0; i < n - 1; ++i) { + if (test_SB_SR_MC_AK(t.b, rounds[i].start.b, rounds[i].round_key.b)) { + verify(&rounds[i + 1].start, &t, "SB+SR+MC+AK"); + } + } + + for (i = 0; i < n; ++i) { + if (test_ISB_ISR(t.b, rounds[i].after_sr.b)) { + verify(&rounds[i].start, &t, "ISB+ISR"); + } + } + + for (i = 0; i < n; ++i) { + if (test_IMC(t.b, rounds[i].after_mc.b)) { + verify(&rounds[i].after_sr, &t, "IMC"); + } + } + + /* The kernel of InvCipher(). */ + for (i = n - 1; i > 0; --i) { + if (test_ISB_ISR_AK_IMC(t.b, rounds[i].after_sr.b, + rounds[i - 1].round_key.b)) { + verify(&rounds[i - 1].after_sr, &t, "ISB+ISR+AK+IMC"); + } + } + + /* + * The kernel of EqInvCipher(). + * We must compute a different round key: apply InvMixColumns to + * the standard round key, per KeyExpansion vs KeyExpansionEIC. + */ + for (i = 1; i < n; ++i) { + if (test_IMC(t.b, rounds[i - 1].round_key.b) && + test_ISB_ISR_IMC_AK(t.b, rounds[i].after_sr.b, t.b)) { + verify(&rounds[i - 1].after_sr, &t, "ISB+ISR+IMC+AK"); + } + } + + return EXIT_SUCCESS; +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index 0606dec118..617f821613 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -74,6 +74,10 @@ ifneq ($(CROSS_CC_HAS_SVE),) AARCH64_TESTS += sve-ioctls sve-ioctls: CFLAGS+=-march=armv8.1-a+sve +AARCH64_TESTS += test-aes +test-aes: CFLAGS += -O -march=armv8-a+aes +test-aes: test-aes-main.c.inc + # Vector SHA1 sha1-vector: CFLAGS=-O3 sha1-vector: sha1.c diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target index f2ee7a4db7..fdf757c6ce 100644 --- a/tests/tcg/i386/Makefile.target +++ b/tests/tcg/i386/Makefile.target @@ -28,6 +28,10 @@ run-test-i386-bmi2: QEMU_OPTS += -cpu max test-i386-adcox: CFLAGS=-O2 run-test-i386-adcox: QEMU_OPTS += -cpu max +test-aes: CFLAGS += -O -msse2 -maes +test-aes: test-aes-main.c.inc +run-test-aes: QEMU_OPTS += -cpu max + # # hello-i386 is a barebones app # diff --git a/tests/tcg/ppc64/Makefile.target b/tests/tcg/ppc64/Makefile.target index b084963b9a..5721c159f2 100644 --- a/tests/tcg/ppc64/Makefile.target +++ b/tests/tcg/ppc64/Makefile.target @@ -36,5 +36,6 @@ run-vector: QEMU_OPTS += -cpu POWER10 PPC64_TESTS += signal_save_restore_xer PPC64_TESTS += xxspltw +PPC64_TESTS += test-aes TESTS += $(PPC64_TESTS) diff --git a/tests/tcg/riscv64/Makefile.target b/tests/tcg/riscv64/Makefile.target index 9973ba3b5f..42993549cb 100644 --- a/tests/tcg/riscv64/Makefile.target +++ b/tests/tcg/riscv64/Makefile.target @@ -9,3 +9,6 @@ TESTS += noexec TESTS += test-noc test-noc: LDFLAGS = -nostdlib -static run-test-noc: QEMU_OPTS += -cpu rv64,c=false + +TESTS += test-aes +run-test-aes: QEMU_OPTS += -cpu rv64,zk=on From patchwork Sun Jul 9 18:28:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700874 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827894wrs; Sun, 9 Jul 2023 11:33:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlEmzWE+ejw4dzjLoxN1fgDy/2qgMVTxmW+DpMG7UAkiSgeiler3s4v1ySUujJnLttDLK9YM X-Received: by 2002:a05:622a:607:b0:400:9b69:7c13 with SMTP id z7-20020a05622a060700b004009b697c13mr11430061qta.59.1688927630383; Sun, 09 Jul 2023 11:33:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927630; cv=none; d=google.com; s=arc-20160816; b=nufZDLhBkb2FTdgIDS3byogls8EvvsHNa6pAu7SPAOGhJ6wYLLH5+nYTbAGldIqduA CwEcFRG2yF25RNqwIkLa05fS6QIDMQDxHsASoAVWWmQNT/g7hJFTEiZHwO3nXmS26M0W i7RA4X8zXbUXNURk2GS0zVGiRtczLXwfHh+M7mcPbTnLGTvujjE5+pHiQJfmLwN9/TcV B32XbWf/IpVzlziFguobSQ0W4fK3tSVWmLYIgqj49thxoFg3fszzSc6Gwe9EB/FtsMDc RQ2UcoHgmzLFmIE1JvCYUsZh5E8M/dP8Sm//vKrHH8piVvU4MYcnXav2SzVba2I61zn5 vP/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:cc:to :from:dkim-signature; bh=oDegPUeqJ78xBO4pGFYHur8C+Wi6RpRKy5K2/MXINzU=; fh=lMWaYJWKNNp5se7C5JIc/IAy1MaLsIKSBhk4MhqnayU=; b=oFXsjIBx/6YUwXDwbGqPpHPI2gYsl7OYkgSBqcSDBMUEn1jT5Yr456dO6DtlMAug1Z YYa1nod1/XAmTW6z+1NUzlMl1PwrSLWd/0HbexMJ7LifiBfw7s/axyqiTFE//0hQyGVZ bxdW3cgkq/299vvGHTs+iPuFlSTUHcJrN3zfzZ3tGODns2W/YVFrhop3zbGiYcc9IKRS Foehed5lwA1+YcXYJLipCEdhGuBKYxNA2Jsb0udYgLGrwOAlbdUk1F/dG84BrciBIf3W HY6gQYDlswcYP2XiiUvQEEmELZC28Yr80sNUYsGnlgcP3+BQdeyzV/pSKMYEPlsinqHJ Eafg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="VWSuGaZ/"; 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-20020ac85856000000b004039ab06ac4si3069551qth.539.2023.07.09.11.33.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:33:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="VWSuGaZ/"; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAV-0008JR-58; Sun, 09 Jul 2023 14:29:59 -0400 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 1qIZAJ-0008ER-RS for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:49 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAF-0000Dt-9S for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:47 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fbea14700bso37624655e9.3 for ; Sun, 09 Jul 2023 11:29:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927381; x=1691519381; 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=oDegPUeqJ78xBO4pGFYHur8C+Wi6RpRKy5K2/MXINzU=; b=VWSuGaZ/IizcHUe5j5GyxFuxzgcCRlwFFbB2hyKcl8pTfua1MVoBaA9HaQbWLVcavf 1uUiqpBXSppuapmOrWssOqnrN7Iu9tLFXr7BcTiXl0cF2/wHlJOGa7BapWEaUQI1tuT1 0R0CGlFaJNqKeTHMk0xgvN3BEDAs8lrbAG1VNCEWBo05pMgZS2n2++ZJZyyMGt78DUib oXol6vx9Kn8kj/ScdWTM3r9aqbLLl5XhuM54T46zwD1OnWR5VLcyWx4kZruPiCoEONUe WU3A07kaW1V2vz+YPConIMqlrGaCrRe+BF7mX5XkvOGvGURu3X3myP1L9/cvRqrDrNki ADqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927381; x=1691519381; 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=oDegPUeqJ78xBO4pGFYHur8C+Wi6RpRKy5K2/MXINzU=; b=U2yvTWuMZ4620A3rykjbE0V1F6quQpjp6webpKa8SIJN4HFQGGO++7R4U9hsWxDkMw OyhUEeSVdjdnf4KZlGQ9v7LkuaTtNigFG7VC3njAXGjJuz7n5DZ7eyNd1A3C0LOS2Yyr LLqxCVGg5WsuKYz7HexDeC01VJGg/HHgjRm0ZXojJbrKi963gyYpls2gp/ujXldOZIwg 91iv57lOutOLwfyLjpFLBaQUPvkhNHTIDC6T1+ZPOYEintVuhZoe3eZZKi6lxG/y5dl2 rxr8O6kn+3w44vGPBLyfz+CKOVv1hgjcWVrhKhpTlRzETTpHimqS7Snc1cTZ5RgqSBOf B+VQ== X-Gm-Message-State: ABy/qLaEoUsqfj7zuZhpcdnqiGSvjlh+/CpButPM7RTKOAwUzuPot90g ggm3GMfayvD7XvhRkhhm9DEq8hx+muwOqXu8EJQSww== X-Received: by 2002:a05:600c:204:b0:3f7:a552:2ec7 with SMTP id 4-20020a05600c020400b003f7a5522ec7mr8417626wmi.33.1688927381595; Sun, 09 Jul 2023 11:29:41 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.29.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:29:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= Subject: [PULL 03/37] target/arm: Move aesmc and aesimc tables to crypto/aes.c Date: Sun, 9 Jul 2023 19:28:18 +0100 Message-Id: <20230709182934.309468-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x330.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We do not currently have a table in crypto/ for just MixColumns. Move both tables for consistency. Acked-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/crypto/aes.h | 6 ++ crypto/aes.c | 140 ++++++++++++++++++++++++++++++++ target/arm/tcg/crypto_helper.c | 143 ++------------------------------- 3 files changed, 151 insertions(+), 138 deletions(-) diff --git a/include/crypto/aes.h b/include/crypto/aes.h index 822d64588c..24b073d569 100644 --- a/include/crypto/aes.h +++ b/include/crypto/aes.h @@ -34,6 +34,12 @@ extern const uint8_t AES_isbox[256]; extern const uint8_t AES_shifts[16]; extern const uint8_t AES_ishifts[16]; +/* AES MixColumns, for use with rot32. */ +extern const uint32_t AES_mc_rot[256]; + +/* AES InvMixColumns, for use with rot32. */ +extern const uint32_t AES_imc_rot[256]; + /* AES InvMixColumns */ /* AES_imc[x][0] = [x].[0e, 09, 0d, 0b]; */ /* AES_imc[x][1] = [x].[0b, 0e, 09, 0d]; */ diff --git a/crypto/aes.c b/crypto/aes.c index af72ff7779..67bb74b8e3 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -116,6 +116,146 @@ const uint8_t AES_ishifts[16] = { 0, 13, 10, 7, 4, 1, 14, 11, 8, 5, 2, 15, 12, 9, 6, 3 }; +/* + * MixColumns lookup table, for use with rot32. + */ +const uint32_t AES_mc_rot[256] = { + 0x00000000, 0x03010102, 0x06020204, 0x05030306, + 0x0c040408, 0x0f05050a, 0x0a06060c, 0x0907070e, + 0x18080810, 0x1b090912, 0x1e0a0a14, 0x1d0b0b16, + 0x140c0c18, 0x170d0d1a, 0x120e0e1c, 0x110f0f1e, + 0x30101020, 0x33111122, 0x36121224, 0x35131326, + 0x3c141428, 0x3f15152a, 0x3a16162c, 0x3917172e, + 0x28181830, 0x2b191932, 0x2e1a1a34, 0x2d1b1b36, + 0x241c1c38, 0x271d1d3a, 0x221e1e3c, 0x211f1f3e, + 0x60202040, 0x63212142, 0x66222244, 0x65232346, + 0x6c242448, 0x6f25254a, 0x6a26264c, 0x6927274e, + 0x78282850, 0x7b292952, 0x7e2a2a54, 0x7d2b2b56, + 0x742c2c58, 0x772d2d5a, 0x722e2e5c, 0x712f2f5e, + 0x50303060, 0x53313162, 0x56323264, 0x55333366, + 0x5c343468, 0x5f35356a, 0x5a36366c, 0x5937376e, + 0x48383870, 0x4b393972, 0x4e3a3a74, 0x4d3b3b76, + 0x443c3c78, 0x473d3d7a, 0x423e3e7c, 0x413f3f7e, + 0xc0404080, 0xc3414182, 0xc6424284, 0xc5434386, + 0xcc444488, 0xcf45458a, 0xca46468c, 0xc947478e, + 0xd8484890, 0xdb494992, 0xde4a4a94, 0xdd4b4b96, + 0xd44c4c98, 0xd74d4d9a, 0xd24e4e9c, 0xd14f4f9e, + 0xf05050a0, 0xf35151a2, 0xf65252a4, 0xf55353a6, + 0xfc5454a8, 0xff5555aa, 0xfa5656ac, 0xf95757ae, + 0xe85858b0, 0xeb5959b2, 0xee5a5ab4, 0xed5b5bb6, + 0xe45c5cb8, 0xe75d5dba, 0xe25e5ebc, 0xe15f5fbe, + 0xa06060c0, 0xa36161c2, 0xa66262c4, 0xa56363c6, + 0xac6464c8, 0xaf6565ca, 0xaa6666cc, 0xa96767ce, + 0xb86868d0, 0xbb6969d2, 0xbe6a6ad4, 0xbd6b6bd6, + 0xb46c6cd8, 0xb76d6dda, 0xb26e6edc, 0xb16f6fde, + 0x907070e0, 0x937171e2, 0x967272e4, 0x957373e6, + 0x9c7474e8, 0x9f7575ea, 0x9a7676ec, 0x997777ee, + 0x887878f0, 0x8b7979f2, 0x8e7a7af4, 0x8d7b7bf6, + 0x847c7cf8, 0x877d7dfa, 0x827e7efc, 0x817f7ffe, + 0x9b80801b, 0x98818119, 0x9d82821f, 0x9e83831d, + 0x97848413, 0x94858511, 0x91868617, 0x92878715, + 0x8388880b, 0x80898909, 0x858a8a0f, 0x868b8b0d, + 0x8f8c8c03, 0x8c8d8d01, 0x898e8e07, 0x8a8f8f05, + 0xab90903b, 0xa8919139, 0xad92923f, 0xae93933d, + 0xa7949433, 0xa4959531, 0xa1969637, 0xa2979735, + 0xb398982b, 0xb0999929, 0xb59a9a2f, 0xb69b9b2d, + 0xbf9c9c23, 0xbc9d9d21, 0xb99e9e27, 0xba9f9f25, + 0xfba0a05b, 0xf8a1a159, 0xfda2a25f, 0xfea3a35d, + 0xf7a4a453, 0xf4a5a551, 0xf1a6a657, 0xf2a7a755, + 0xe3a8a84b, 0xe0a9a949, 0xe5aaaa4f, 0xe6abab4d, + 0xefacac43, 0xecadad41, 0xe9aeae47, 0xeaafaf45, + 0xcbb0b07b, 0xc8b1b179, 0xcdb2b27f, 0xceb3b37d, + 0xc7b4b473, 0xc4b5b571, 0xc1b6b677, 0xc2b7b775, + 0xd3b8b86b, 0xd0b9b969, 0xd5baba6f, 0xd6bbbb6d, + 0xdfbcbc63, 0xdcbdbd61, 0xd9bebe67, 0xdabfbf65, + 0x5bc0c09b, 0x58c1c199, 0x5dc2c29f, 0x5ec3c39d, + 0x57c4c493, 0x54c5c591, 0x51c6c697, 0x52c7c795, + 0x43c8c88b, 0x40c9c989, 0x45caca8f, 0x46cbcb8d, + 0x4fcccc83, 0x4ccdcd81, 0x49cece87, 0x4acfcf85, + 0x6bd0d0bb, 0x68d1d1b9, 0x6dd2d2bf, 0x6ed3d3bd, + 0x67d4d4b3, 0x64d5d5b1, 0x61d6d6b7, 0x62d7d7b5, + 0x73d8d8ab, 0x70d9d9a9, 0x75dadaaf, 0x76dbdbad, + 0x7fdcdca3, 0x7cdddda1, 0x79dedea7, 0x7adfdfa5, + 0x3be0e0db, 0x38e1e1d9, 0x3de2e2df, 0x3ee3e3dd, + 0x37e4e4d3, 0x34e5e5d1, 0x31e6e6d7, 0x32e7e7d5, + 0x23e8e8cb, 0x20e9e9c9, 0x25eaeacf, 0x26ebebcd, + 0x2fececc3, 0x2cededc1, 0x29eeeec7, 0x2aefefc5, + 0x0bf0f0fb, 0x08f1f1f9, 0x0df2f2ff, 0x0ef3f3fd, + 0x07f4f4f3, 0x04f5f5f1, 0x01f6f6f7, 0x02f7f7f5, + 0x13f8f8eb, 0x10f9f9e9, 0x15fafaef, 0x16fbfbed, + 0x1ffcfce3, 0x1cfdfde1, 0x19fefee7, 0x1affffe5, +}; + +/* + * Inverse MixColumns lookup table, for use with rot32. + */ +const uint32_t AES_imc_rot[256] = { + 0x00000000, 0x0b0d090e, 0x161a121c, 0x1d171b12, + 0x2c342438, 0x27392d36, 0x3a2e3624, 0x31233f2a, + 0x58684870, 0x5365417e, 0x4e725a6c, 0x457f5362, + 0x745c6c48, 0x7f516546, 0x62467e54, 0x694b775a, + 0xb0d090e0, 0xbbdd99ee, 0xa6ca82fc, 0xadc78bf2, + 0x9ce4b4d8, 0x97e9bdd6, 0x8afea6c4, 0x81f3afca, + 0xe8b8d890, 0xe3b5d19e, 0xfea2ca8c, 0xf5afc382, + 0xc48cfca8, 0xcf81f5a6, 0xd296eeb4, 0xd99be7ba, + 0x7bbb3bdb, 0x70b632d5, 0x6da129c7, 0x66ac20c9, + 0x578f1fe3, 0x5c8216ed, 0x41950dff, 0x4a9804f1, + 0x23d373ab, 0x28de7aa5, 0x35c961b7, 0x3ec468b9, + 0x0fe75793, 0x04ea5e9d, 0x19fd458f, 0x12f04c81, + 0xcb6bab3b, 0xc066a235, 0xdd71b927, 0xd67cb029, + 0xe75f8f03, 0xec52860d, 0xf1459d1f, 0xfa489411, + 0x9303e34b, 0x980eea45, 0x8519f157, 0x8e14f859, + 0xbf37c773, 0xb43ace7d, 0xa92dd56f, 0xa220dc61, + 0xf66d76ad, 0xfd607fa3, 0xe07764b1, 0xeb7a6dbf, + 0xda595295, 0xd1545b9b, 0xcc434089, 0xc74e4987, + 0xae053edd, 0xa50837d3, 0xb81f2cc1, 0xb31225cf, + 0x82311ae5, 0x893c13eb, 0x942b08f9, 0x9f2601f7, + 0x46bde64d, 0x4db0ef43, 0x50a7f451, 0x5baafd5f, + 0x6a89c275, 0x6184cb7b, 0x7c93d069, 0x779ed967, + 0x1ed5ae3d, 0x15d8a733, 0x08cfbc21, 0x03c2b52f, + 0x32e18a05, 0x39ec830b, 0x24fb9819, 0x2ff69117, + 0x8dd64d76, 0x86db4478, 0x9bcc5f6a, 0x90c15664, + 0xa1e2694e, 0xaaef6040, 0xb7f87b52, 0xbcf5725c, + 0xd5be0506, 0xdeb30c08, 0xc3a4171a, 0xc8a91e14, + 0xf98a213e, 0xf2872830, 0xef903322, 0xe49d3a2c, + 0x3d06dd96, 0x360bd498, 0x2b1ccf8a, 0x2011c684, + 0x1132f9ae, 0x1a3ff0a0, 0x0728ebb2, 0x0c25e2bc, + 0x656e95e6, 0x6e639ce8, 0x737487fa, 0x78798ef4, + 0x495ab1de, 0x4257b8d0, 0x5f40a3c2, 0x544daacc, + 0xf7daec41, 0xfcd7e54f, 0xe1c0fe5d, 0xeacdf753, + 0xdbeec879, 0xd0e3c177, 0xcdf4da65, 0xc6f9d36b, + 0xafb2a431, 0xa4bfad3f, 0xb9a8b62d, 0xb2a5bf23, + 0x83868009, 0x888b8907, 0x959c9215, 0x9e919b1b, + 0x470a7ca1, 0x4c0775af, 0x51106ebd, 0x5a1d67b3, + 0x6b3e5899, 0x60335197, 0x7d244a85, 0x7629438b, + 0x1f6234d1, 0x146f3ddf, 0x097826cd, 0x02752fc3, + 0x335610e9, 0x385b19e7, 0x254c02f5, 0x2e410bfb, + 0x8c61d79a, 0x876cde94, 0x9a7bc586, 0x9176cc88, + 0xa055f3a2, 0xab58faac, 0xb64fe1be, 0xbd42e8b0, + 0xd4099fea, 0xdf0496e4, 0xc2138df6, 0xc91e84f8, + 0xf83dbbd2, 0xf330b2dc, 0xee27a9ce, 0xe52aa0c0, + 0x3cb1477a, 0x37bc4e74, 0x2aab5566, 0x21a65c68, + 0x10856342, 0x1b886a4c, 0x069f715e, 0x0d927850, + 0x64d90f0a, 0x6fd40604, 0x72c31d16, 0x79ce1418, + 0x48ed2b32, 0x43e0223c, 0x5ef7392e, 0x55fa3020, + 0x01b79aec, 0x0aba93e2, 0x17ad88f0, 0x1ca081fe, + 0x2d83bed4, 0x268eb7da, 0x3b99acc8, 0x3094a5c6, + 0x59dfd29c, 0x52d2db92, 0x4fc5c080, 0x44c8c98e, + 0x75ebf6a4, 0x7ee6ffaa, 0x63f1e4b8, 0x68fcedb6, + 0xb1670a0c, 0xba6a0302, 0xa77d1810, 0xac70111e, + 0x9d532e34, 0x965e273a, 0x8b493c28, 0x80443526, + 0xe90f427c, 0xe2024b72, 0xff155060, 0xf418596e, + 0xc53b6644, 0xce366f4a, 0xd3217458, 0xd82c7d56, + 0x7a0ca137, 0x7101a839, 0x6c16b32b, 0x671bba25, + 0x5638850f, 0x5d358c01, 0x40229713, 0x4b2f9e1d, + 0x2264e947, 0x2969e049, 0x347efb5b, 0x3f73f255, + 0x0e50cd7f, 0x055dc471, 0x184adf63, 0x1347d66d, + 0xcadc31d7, 0xc1d138d9, 0xdcc623cb, 0xd7cb2ac5, + 0xe6e815ef, 0xede51ce1, 0xf0f207f3, 0xfbff0efd, + 0x92b479a7, 0x99b970a9, 0x84ae6bbb, 0x8fa362b5, + 0xbe805d9f, 0xb58d5491, 0xa89a4f83, 0xa397468d, +}; + /* AES_imc[x][0] = [x].[0e, 09, 0d, 0b]; */ /* AES_imc[x][1] = [x].[0b, 0e, 09, 0d]; */ /* AES_imc[x][2] = [x].[0d, 0b, 0e, 09]; */ diff --git a/target/arm/tcg/crypto_helper.c b/target/arm/tcg/crypto_helper.c index d28690321f..06254939d2 100644 --- a/target/arm/tcg/crypto_helper.c +++ b/target/arm/tcg/crypto_helper.c @@ -80,149 +80,16 @@ void HELPER(crypto_aese)(void *vd, void *vn, void *vm, uint32_t desc) static void do_crypto_aesmc(uint64_t *rd, uint64_t *rm, bool decrypt) { - static uint32_t const mc[][256] = { { - /* MixColumns lookup table */ - 0x00000000, 0x03010102, 0x06020204, 0x05030306, - 0x0c040408, 0x0f05050a, 0x0a06060c, 0x0907070e, - 0x18080810, 0x1b090912, 0x1e0a0a14, 0x1d0b0b16, - 0x140c0c18, 0x170d0d1a, 0x120e0e1c, 0x110f0f1e, - 0x30101020, 0x33111122, 0x36121224, 0x35131326, - 0x3c141428, 0x3f15152a, 0x3a16162c, 0x3917172e, - 0x28181830, 0x2b191932, 0x2e1a1a34, 0x2d1b1b36, - 0x241c1c38, 0x271d1d3a, 0x221e1e3c, 0x211f1f3e, - 0x60202040, 0x63212142, 0x66222244, 0x65232346, - 0x6c242448, 0x6f25254a, 0x6a26264c, 0x6927274e, - 0x78282850, 0x7b292952, 0x7e2a2a54, 0x7d2b2b56, - 0x742c2c58, 0x772d2d5a, 0x722e2e5c, 0x712f2f5e, - 0x50303060, 0x53313162, 0x56323264, 0x55333366, - 0x5c343468, 0x5f35356a, 0x5a36366c, 0x5937376e, - 0x48383870, 0x4b393972, 0x4e3a3a74, 0x4d3b3b76, - 0x443c3c78, 0x473d3d7a, 0x423e3e7c, 0x413f3f7e, - 0xc0404080, 0xc3414182, 0xc6424284, 0xc5434386, - 0xcc444488, 0xcf45458a, 0xca46468c, 0xc947478e, - 0xd8484890, 0xdb494992, 0xde4a4a94, 0xdd4b4b96, - 0xd44c4c98, 0xd74d4d9a, 0xd24e4e9c, 0xd14f4f9e, - 0xf05050a0, 0xf35151a2, 0xf65252a4, 0xf55353a6, - 0xfc5454a8, 0xff5555aa, 0xfa5656ac, 0xf95757ae, - 0xe85858b0, 0xeb5959b2, 0xee5a5ab4, 0xed5b5bb6, - 0xe45c5cb8, 0xe75d5dba, 0xe25e5ebc, 0xe15f5fbe, - 0xa06060c0, 0xa36161c2, 0xa66262c4, 0xa56363c6, - 0xac6464c8, 0xaf6565ca, 0xaa6666cc, 0xa96767ce, - 0xb86868d0, 0xbb6969d2, 0xbe6a6ad4, 0xbd6b6bd6, - 0xb46c6cd8, 0xb76d6dda, 0xb26e6edc, 0xb16f6fde, - 0x907070e0, 0x937171e2, 0x967272e4, 0x957373e6, - 0x9c7474e8, 0x9f7575ea, 0x9a7676ec, 0x997777ee, - 0x887878f0, 0x8b7979f2, 0x8e7a7af4, 0x8d7b7bf6, - 0x847c7cf8, 0x877d7dfa, 0x827e7efc, 0x817f7ffe, - 0x9b80801b, 0x98818119, 0x9d82821f, 0x9e83831d, - 0x97848413, 0x94858511, 0x91868617, 0x92878715, - 0x8388880b, 0x80898909, 0x858a8a0f, 0x868b8b0d, - 0x8f8c8c03, 0x8c8d8d01, 0x898e8e07, 0x8a8f8f05, - 0xab90903b, 0xa8919139, 0xad92923f, 0xae93933d, - 0xa7949433, 0xa4959531, 0xa1969637, 0xa2979735, - 0xb398982b, 0xb0999929, 0xb59a9a2f, 0xb69b9b2d, - 0xbf9c9c23, 0xbc9d9d21, 0xb99e9e27, 0xba9f9f25, - 0xfba0a05b, 0xf8a1a159, 0xfda2a25f, 0xfea3a35d, - 0xf7a4a453, 0xf4a5a551, 0xf1a6a657, 0xf2a7a755, - 0xe3a8a84b, 0xe0a9a949, 0xe5aaaa4f, 0xe6abab4d, - 0xefacac43, 0xecadad41, 0xe9aeae47, 0xeaafaf45, - 0xcbb0b07b, 0xc8b1b179, 0xcdb2b27f, 0xceb3b37d, - 0xc7b4b473, 0xc4b5b571, 0xc1b6b677, 0xc2b7b775, - 0xd3b8b86b, 0xd0b9b969, 0xd5baba6f, 0xd6bbbb6d, - 0xdfbcbc63, 0xdcbdbd61, 0xd9bebe67, 0xdabfbf65, - 0x5bc0c09b, 0x58c1c199, 0x5dc2c29f, 0x5ec3c39d, - 0x57c4c493, 0x54c5c591, 0x51c6c697, 0x52c7c795, - 0x43c8c88b, 0x40c9c989, 0x45caca8f, 0x46cbcb8d, - 0x4fcccc83, 0x4ccdcd81, 0x49cece87, 0x4acfcf85, - 0x6bd0d0bb, 0x68d1d1b9, 0x6dd2d2bf, 0x6ed3d3bd, - 0x67d4d4b3, 0x64d5d5b1, 0x61d6d6b7, 0x62d7d7b5, - 0x73d8d8ab, 0x70d9d9a9, 0x75dadaaf, 0x76dbdbad, - 0x7fdcdca3, 0x7cdddda1, 0x79dedea7, 0x7adfdfa5, - 0x3be0e0db, 0x38e1e1d9, 0x3de2e2df, 0x3ee3e3dd, - 0x37e4e4d3, 0x34e5e5d1, 0x31e6e6d7, 0x32e7e7d5, - 0x23e8e8cb, 0x20e9e9c9, 0x25eaeacf, 0x26ebebcd, - 0x2fececc3, 0x2cededc1, 0x29eeeec7, 0x2aefefc5, - 0x0bf0f0fb, 0x08f1f1f9, 0x0df2f2ff, 0x0ef3f3fd, - 0x07f4f4f3, 0x04f5f5f1, 0x01f6f6f7, 0x02f7f7f5, - 0x13f8f8eb, 0x10f9f9e9, 0x15fafaef, 0x16fbfbed, - 0x1ffcfce3, 0x1cfdfde1, 0x19fefee7, 0x1affffe5, - }, { - /* Inverse MixColumns lookup table */ - 0x00000000, 0x0b0d090e, 0x161a121c, 0x1d171b12, - 0x2c342438, 0x27392d36, 0x3a2e3624, 0x31233f2a, - 0x58684870, 0x5365417e, 0x4e725a6c, 0x457f5362, - 0x745c6c48, 0x7f516546, 0x62467e54, 0x694b775a, - 0xb0d090e0, 0xbbdd99ee, 0xa6ca82fc, 0xadc78bf2, - 0x9ce4b4d8, 0x97e9bdd6, 0x8afea6c4, 0x81f3afca, - 0xe8b8d890, 0xe3b5d19e, 0xfea2ca8c, 0xf5afc382, - 0xc48cfca8, 0xcf81f5a6, 0xd296eeb4, 0xd99be7ba, - 0x7bbb3bdb, 0x70b632d5, 0x6da129c7, 0x66ac20c9, - 0x578f1fe3, 0x5c8216ed, 0x41950dff, 0x4a9804f1, - 0x23d373ab, 0x28de7aa5, 0x35c961b7, 0x3ec468b9, - 0x0fe75793, 0x04ea5e9d, 0x19fd458f, 0x12f04c81, - 0xcb6bab3b, 0xc066a235, 0xdd71b927, 0xd67cb029, - 0xe75f8f03, 0xec52860d, 0xf1459d1f, 0xfa489411, - 0x9303e34b, 0x980eea45, 0x8519f157, 0x8e14f859, - 0xbf37c773, 0xb43ace7d, 0xa92dd56f, 0xa220dc61, - 0xf66d76ad, 0xfd607fa3, 0xe07764b1, 0xeb7a6dbf, - 0xda595295, 0xd1545b9b, 0xcc434089, 0xc74e4987, - 0xae053edd, 0xa50837d3, 0xb81f2cc1, 0xb31225cf, - 0x82311ae5, 0x893c13eb, 0x942b08f9, 0x9f2601f7, - 0x46bde64d, 0x4db0ef43, 0x50a7f451, 0x5baafd5f, - 0x6a89c275, 0x6184cb7b, 0x7c93d069, 0x779ed967, - 0x1ed5ae3d, 0x15d8a733, 0x08cfbc21, 0x03c2b52f, - 0x32e18a05, 0x39ec830b, 0x24fb9819, 0x2ff69117, - 0x8dd64d76, 0x86db4478, 0x9bcc5f6a, 0x90c15664, - 0xa1e2694e, 0xaaef6040, 0xb7f87b52, 0xbcf5725c, - 0xd5be0506, 0xdeb30c08, 0xc3a4171a, 0xc8a91e14, - 0xf98a213e, 0xf2872830, 0xef903322, 0xe49d3a2c, - 0x3d06dd96, 0x360bd498, 0x2b1ccf8a, 0x2011c684, - 0x1132f9ae, 0x1a3ff0a0, 0x0728ebb2, 0x0c25e2bc, - 0x656e95e6, 0x6e639ce8, 0x737487fa, 0x78798ef4, - 0x495ab1de, 0x4257b8d0, 0x5f40a3c2, 0x544daacc, - 0xf7daec41, 0xfcd7e54f, 0xe1c0fe5d, 0xeacdf753, - 0xdbeec879, 0xd0e3c177, 0xcdf4da65, 0xc6f9d36b, - 0xafb2a431, 0xa4bfad3f, 0xb9a8b62d, 0xb2a5bf23, - 0x83868009, 0x888b8907, 0x959c9215, 0x9e919b1b, - 0x470a7ca1, 0x4c0775af, 0x51106ebd, 0x5a1d67b3, - 0x6b3e5899, 0x60335197, 0x7d244a85, 0x7629438b, - 0x1f6234d1, 0x146f3ddf, 0x097826cd, 0x02752fc3, - 0x335610e9, 0x385b19e7, 0x254c02f5, 0x2e410bfb, - 0x8c61d79a, 0x876cde94, 0x9a7bc586, 0x9176cc88, - 0xa055f3a2, 0xab58faac, 0xb64fe1be, 0xbd42e8b0, - 0xd4099fea, 0xdf0496e4, 0xc2138df6, 0xc91e84f8, - 0xf83dbbd2, 0xf330b2dc, 0xee27a9ce, 0xe52aa0c0, - 0x3cb1477a, 0x37bc4e74, 0x2aab5566, 0x21a65c68, - 0x10856342, 0x1b886a4c, 0x069f715e, 0x0d927850, - 0x64d90f0a, 0x6fd40604, 0x72c31d16, 0x79ce1418, - 0x48ed2b32, 0x43e0223c, 0x5ef7392e, 0x55fa3020, - 0x01b79aec, 0x0aba93e2, 0x17ad88f0, 0x1ca081fe, - 0x2d83bed4, 0x268eb7da, 0x3b99acc8, 0x3094a5c6, - 0x59dfd29c, 0x52d2db92, 0x4fc5c080, 0x44c8c98e, - 0x75ebf6a4, 0x7ee6ffaa, 0x63f1e4b8, 0x68fcedb6, - 0xb1670a0c, 0xba6a0302, 0xa77d1810, 0xac70111e, - 0x9d532e34, 0x965e273a, 0x8b493c28, 0x80443526, - 0xe90f427c, 0xe2024b72, 0xff155060, 0xf418596e, - 0xc53b6644, 0xce366f4a, 0xd3217458, 0xd82c7d56, - 0x7a0ca137, 0x7101a839, 0x6c16b32b, 0x671bba25, - 0x5638850f, 0x5d358c01, 0x40229713, 0x4b2f9e1d, - 0x2264e947, 0x2969e049, 0x347efb5b, 0x3f73f255, - 0x0e50cd7f, 0x055dc471, 0x184adf63, 0x1347d66d, - 0xcadc31d7, 0xc1d138d9, 0xdcc623cb, 0xd7cb2ac5, - 0xe6e815ef, 0xede51ce1, 0xf0f207f3, 0xfbff0efd, - 0x92b479a7, 0x99b970a9, 0x84ae6bbb, 0x8fa362b5, - 0xbe805d9f, 0xb58d5491, 0xa89a4f83, 0xa397468d, - } }; - union CRYPTO_STATE st = { .l = { rm[0], rm[1] } }; + const uint32_t *mc = decrypt ? AES_imc_rot : AES_mc_rot; int i; for (i = 0; i < 16; i += 4) { CR_ST_WORD(st, i >> 2) = - mc[decrypt][CR_ST_BYTE(st, i)] ^ - rol32(mc[decrypt][CR_ST_BYTE(st, i + 1)], 8) ^ - rol32(mc[decrypt][CR_ST_BYTE(st, i + 2)], 16) ^ - rol32(mc[decrypt][CR_ST_BYTE(st, i + 3)], 24); + mc[CR_ST_BYTE(st, i)] ^ + rol32(mc[CR_ST_BYTE(st, i + 1)], 8) ^ + rol32(mc[CR_ST_BYTE(st, i + 2)], 16) ^ + rol32(mc[CR_ST_BYTE(st, i + 3)], 24); } rd[0] = st.l[0]; From patchwork Sun Jul 9 18:28:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700856 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827357wrs; Sun, 9 Jul 2023 11:31:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlFsAQ3txA2FA9RgL50ZO/0nT7fUKg0CRAyhvT3dJ7FoR0rAZqEoT18bQsJgum6xH5hh51c1 X-Received: by 2002:ac8:59c1:0:b0:3f5:19e4:34ce with SMTP id f1-20020ac859c1000000b003f519e434cemr12635113qtf.48.1688927518616; Sun, 09 Jul 2023 11:31:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927518; cv=none; d=google.com; s=arc-20160816; b=RdL1NOfHFr8DqOLxhOLWmRQxLcYoawMrhFa7vlbKxbLJEyRPC8bRK/nqURrci7A2Ki r+aXvaPhEQbwbDA4KvfuNEfM8oO9S116HdDX2iu5rfxRikPzWRt4NLV/YSkPQYAAJC62 STlCSBJoTRA+dHwmx9BS+mxOdjBAxglrJzVSC5yDWMafA+L4M9j+Bi38RBjfDYrnmjqx rsu+078JkGM/MMUA7k+Y87CnAga+HnB6l0RNfjHAozAeVnWIcgViJZ+UxvVffqTeg1Kq /9AXGejOKL4Eahrs/DHRGmcAxMtxSWuzwCs7mlrMAoh3qo/OONcUa70nc5HqimcP3w+T MT+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:cc:to :from:dkim-signature; bh=gLgfXZyf9aATX9TfQItUdKukGg6cdQDyWQ8EagJh33A=; fh=lMWaYJWKNNp5se7C5JIc/IAy1MaLsIKSBhk4MhqnayU=; b=DSAczTE3sB5TvHdBblqjnzojij0mnZ7EADkxtzUe3vMZuzAMP9z8Iq86WAqhfVWBNm csHH5N12UsCA041hNAx9ZmE9Kv2T8pAVXYDCrONzxcmBbS+uBq/JMh1mfUmbuVBWFiRR HGDjYorpDsxRyFCnwWptXsSILQS5+vDjLFk9K9bZ3qkEzIYkUuYqEn18hBRqxlTbLzMt mCgDT7lf/ttyIPjp0+RYjnSXwAZ2y4t3ttXUuUb6O+/Mvib3zGgqbU1OLeEQniBX/5/I hURq8EEtt5GXvWgmYt1As5ndwQWN8vXH50Amr7MUvrIE9ftTePOH7wyYIPJztzyPLktk WyKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iAUj9O7+; 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 b8-20020a0ccd08000000b006261566ac3asi4778860qvm.90.2023.07.09.11.31.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:31:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iAUj9O7+; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAU-0008JE-6x; Sun, 09 Jul 2023 14:29:58 -0400 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 1qIZAJ-0008EP-9q for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:48 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAG-0000E0-PC for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:47 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-307d58b3efbso3573397f8f.0 for ; Sun, 09 Jul 2023 11:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927382; x=1691519382; 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=gLgfXZyf9aATX9TfQItUdKukGg6cdQDyWQ8EagJh33A=; b=iAUj9O7+LFwt3Zf+ETwt8UG82wsavqE/EP9S3iITcm5ub39DVylbXA/wARxo1Le897 BtyzUn3DcgjPfqCwm2dkSj4zTWwdk7V0UJ8WzF1T0Xdmkp/VUKEyORUfBPGJY4B++v2a M2SmjClicyQfkAORq33hNNTGiKZWsTJ9xHowVjC2fZft1W7iJL9aLVvRFYmvfYBFb0pT Xk+BCa9LHmOkjeTCDj4LUaWlm5O4+crXZOVg4qRxIxbL8YbXju/arAL6OJJXvoTVczc1 netakwK5hgyTq3M2u/5BzTC7cueX+4Agvr/92h7P+/rYI7Iy4OZlFOVOFWW0D7DEtVzl Q0/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927382; x=1691519382; 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=gLgfXZyf9aATX9TfQItUdKukGg6cdQDyWQ8EagJh33A=; b=i6TbulDW38I4ZSnFQQm0o3pZFeMHr3IahvjB9niyJU4g9iz3dV/ufoU0pZYTENQA8I V1Tz1NTBRfLAFysHQVB8DC0WWmZf6Dp4OYFHLA+JTOOLeMXBxb8BH75S5XUnzgVeP+n9 qT7QPdKxp8AXkfamdfUWugrh7V+RDmeN+dfoVLDfUiHOmTSFrWL0IpxjgvrlgdkptSR6 ko1CdR6ehkovBs6qsr23xF/F6FsmDLANE3DbGpQlbutMTvt3k7WpefVu173jEP9O5siN R1kElUpLkFGxlB3ft4gnLnPVBjEeT0BhnfEJNhAnVm9zXXlb27sOPnEliBYDBjetPqEZ 04Dw== X-Gm-Message-State: ABy/qLboUC69hUbyfJfb6A4aFX26cSXkl5Hepu65jPhjnlTXMjmVcFAx rBrH4+mggOVRl2vffFpD6DnuYHpm+5U6xkwCpVqavg== X-Received: by 2002:a5d:5303:0:b0:313:deda:c444 with SMTP id e3-20020a5d5303000000b00313dedac444mr7925547wrv.24.1688927382497; Sun, 09 Jul 2023 11:29:42 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:29:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= Subject: [PULL 04/37] crypto/aes: Add AES_SH, AES_ISH macros Date: Sun, 9 Jul 2023 19:28:19 +0100 Message-Id: <20230709182934.309468-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x435.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These macros will constant fold and avoid the indirection through memory when fully unrolling some new primitives. Acked-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- crypto/aes.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/crypto/aes.c b/crypto/aes.c index 67bb74b8e3..e65c97e0c1 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -108,12 +108,24 @@ const uint8_t AES_isbox[256] = { 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D, }; +/* AES ShiftRows, for complete unrolling. */ +#define AES_SH(X) (((X) * 5) & 15) + const uint8_t AES_shifts[16] = { - 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11 + AES_SH(0x0), AES_SH(0x1), AES_SH(0x2), AES_SH(0x3), + AES_SH(0x4), AES_SH(0x5), AES_SH(0x6), AES_SH(0x7), + AES_SH(0x8), AES_SH(0x9), AES_SH(0xA), AES_SH(0xB), + AES_SH(0xC), AES_SH(0xD), AES_SH(0xE), AES_SH(0xF), }; +/* AES InvShiftRows, for complete unrolling. */ +#define AES_ISH(X) (((X) * 13) & 15) + const uint8_t AES_ishifts[16] = { - 0, 13, 10, 7, 4, 1, 14, 11, 8, 5, 2, 15, 12, 9, 6, 3 + AES_ISH(0x0), AES_ISH(0x1), AES_ISH(0x2), AES_ISH(0x3), + AES_ISH(0x4), AES_ISH(0x5), AES_ISH(0x6), AES_ISH(0x7), + AES_ISH(0x8), AES_ISH(0x9), AES_ISH(0xA), AES_ISH(0xB), + AES_ISH(0xC), AES_ISH(0xD), AES_ISH(0xE), AES_ISH(0xF), }; /* From patchwork Sun Jul 9 18:28:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700892 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4829003wrs; Sun, 9 Jul 2023 11:38:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlFYt3Yd7zsM+1F73+RVd80TPiU5XcCldKc/bSkNpUgQzn+uxqH5wVRrVb1rDOrkLGWKep1M X-Received: by 2002:a0c:db02:0:b0:635:ddcf:144b with SMTP id d2-20020a0cdb02000000b00635ddcf144bmr9032247qvk.54.1688927901725; Sun, 09 Jul 2023 11:38:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927901; cv=none; d=google.com; s=arc-20160816; b=Dh+S/jr3OZ+FCBdjmYmiew/yWxiakO6TDqea9yyw8Fa2BIcjIwfNpDwtBxcsgXjFTr JqoOGxf/jhBU6IrEEGVW6z09nmo9BQNuYXqaGF7Prg/0c2bqya6vx1NVKfPYfH5/IhTm rnkj7edGNLAeuqd145BFS8qtPX6O4ItUfdV7gByxKtrKPIsf9gQTxqxPSP72YG4F8HHr Mpb2DD1C9ls5tOYmhHtc8bgKleD/XK/4++2f652+XM0lL9AqfGMJAJMQU9yo+0hr2XSX mUdaOoPM5AWTS1ckA31xWp8pdbOuQxU5NQterGJuImk0++VyRCuLILR6W3atq0X0xz3x QQtw== 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:cc:to :from:dkim-signature; bh=LO73AWeIHAR2oL9a8MGDntKx1EKSzMSEdZSpHf3WsVU=; fh=3IEiF/YPZ00TE94rna3Orj/L+TRFhpuNf7ElRJz3ubE=; b=uPyO2Q9IfDxM38A4KimNGerI2L9AmunRsl+ZvCFtkN9K5BGAmob4XifJSXt5NApmbz bYM1fcCGY3IbM7ar9osxpjGEC3q/ygcu1hw+FrHcT6A2swnen5u+gNHE+y/QfIX9dVez HfpzHfZAJNTZBFKtvByr9zVCnn1exO1zT16HBYnm+Hw5Lvb7P8fUNqr+0UPO6ZYAjoZe xmy7juLEc/MIh60AcU3LzkBQuuWcEaMcT37ZJmIJuC6AtSD4/dQHmAjlGO21bwhPy+ma sRTwVbCCGJzsIrfIS36z5REbMcVUyUAoAOgUyeqRXEnKfd4Hf7lj7LDBYvC/EM/roXca PB6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UuwapAyz; 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 z11-20020a0cf24b000000b00626080fa02asi4937568qvl.312.2023.07.09.11.38.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:38:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UuwapAyz; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAP-0008GQ-Pw; Sun, 09 Jul 2023 14:29:53 -0400 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 1qIZAK-0008ET-T8 for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:50 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAI-0000EO-8I for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:48 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3fbc5d5742bso41758125e9.2 for ; Sun, 09 Jul 2023 11:29:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927385; x=1691519385; 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=LO73AWeIHAR2oL9a8MGDntKx1EKSzMSEdZSpHf3WsVU=; b=UuwapAyzwGqXFa/V/y7gjb+mDezUyPb+DxGQAC/ul/nQ4yScL4ekJv8YsBNoDWa5JX e4GdfpJqsh0HUaIBCcTzkpPA0WYcn89SvbDPPHCLcXtSqvpjRUDiDqFc8wFf0ETRXo9I yVTvW1BHkg0BdG9VHcdWhh/UTWG8k5c5qSLE/Rg+TJQ+pO2fMovHxh/eedjTATHghMrG wkydZoexNNwrOdPukNTQMuIYveOeJMFqNo9BLL1arHylnxykrwmUOmyXtqj8j9ibmGFu GmwN3v1l5PpCVIlbuZF1d7TD5T4RO77fc3RYO7hU3DeY9dre08E1P755c/QUiaONFMmT P2yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927385; x=1691519385; 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=LO73AWeIHAR2oL9a8MGDntKx1EKSzMSEdZSpHf3WsVU=; b=TeXuEGmtDPRh9oIPIM+5eqp4LqIZxli42YXu5sq8CAF+Uncsir5+JcbteIATpP1Esi 3btSjNJWWtHKfXevkQYYA1cKthlxfiua++cEVs8paNYFZLTt67Kir8vO1AURbvXNWf7U UFQyQnGmD+UXxZJUqMihR0M7q3rJfPyi5xHSIgOkcPczmqQWvr7tnAe7ctsX9W9WvNvI acRdNdgDMEsjpQ/2fbbUCjtr2QK152pYTN0xNsljNo3IzKTFwtTOJKi5F5B9nhk9HX/m HDYGZtH3hIvLVscHMlZg/vi3Eeer4ROo813/snoFYtCRnVuCOIYd/92eTenphrOjJMX8 UmPg== X-Gm-Message-State: ABy/qLZqTcoMwot6ewE/1CUf7z78HZke5gkkC9RG7USRdOxbWCFlw+tn w2Ah0E8xyWMdHQBMLO2g7MOOKb2JyArIXrvr0oHUfg== X-Received: by 2002:a05:600c:3785:b0:3fb:a0fc:1ba1 with SMTP id o5-20020a05600c378500b003fba0fc1ba1mr11048130wmr.35.1688927385044; Sun, 09 Jul 2023 11:29:45 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:29:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 05/45] linux-user: Use abi_ullong not uint64_t in syscall_defs.h Date: Sun, 9 Jul 2023 19:28:22 +0100 Message-Id: <20230709182934.309468-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x334.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Be careful not to change linux_dirent64, which is a host structure. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/syscall_defs.h | 72 +++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index caaa895bec..0af7249330 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1444,8 +1444,8 @@ struct target_stat64 { unsigned char __pad0[6]; unsigned short st_dev; - uint64_t st_ino; - uint64_t st_nlink; + abi_ullong st_ino; + abi_ullong st_nlink; unsigned int st_mode; @@ -1501,7 +1501,7 @@ struct target_stat64 { unsigned char __pad0[6]; unsigned short st_dev; - uint64_t st_ino; + abi_ullong st_ino; unsigned int st_mode; unsigned int st_nlink; @@ -1618,7 +1618,7 @@ struct target_stat { /* FIXME: Microblaze no-mmu user-space has a difference stat64 layout... */ #define TARGET_HAS_STRUCT_STAT64 struct QEMU_PACKED target_stat64 { - uint64_t st_dev; + abi_ullong st_dev; #define TARGET_STAT64_HAS_BROKEN_ST_INO 1 abi_uint pad0; abi_uint __st_ino; @@ -1627,8 +1627,8 @@ struct QEMU_PACKED target_stat64 { abi_uint st_nlink; abi_uint st_uid; abi_uint st_gid; - uint64_t st_rdev; - uint64_t __pad1; + abi_ullong st_rdev; + abi_ullong __pad1; int64_t st_size; abi_int st_blksize; @@ -1641,7 +1641,7 @@ struct QEMU_PACKED target_stat64 { unsigned int target_st_mtime_nsec; int target_st_ctime; unsigned int target_st_ctime_nsec; - uint64_t st_ino; + abi_ullong st_ino; }; #elif defined(TARGET_M68K) @@ -1753,7 +1753,7 @@ struct target_stat { struct target_stat { abi_ulong st_dev; abi_ulong st_pad0[3]; /* Reserved for st_dev expansion */ - uint64_t st_ino; + abi_ullong st_ino; unsigned int st_mode; unsigned int st_nlink; int st_uid; @@ -1813,7 +1813,7 @@ struct target_stat64 { abi_ulong st_dev; abi_ulong st_pad0[3]; /* Reserved for st_dev expansion */ - uint64_t st_ino; + abi_ullong st_ino; unsigned int st_mode; unsigned int st_nlink; @@ -2044,17 +2044,17 @@ struct target_stat { #define TARGET_HAS_STRUCT_STAT64 struct target_stat64 { - uint64_t st_dev; /* Device */ - uint64_t st_ino; /* File serial number */ + abi_ullong st_dev; /* Device */ + abi_ullong st_ino; /* File serial number */ unsigned int st_mode; /* File mode. */ unsigned int st_nlink; /* Link count. */ unsigned int st_uid; /* User ID of the file's owner. */ unsigned int st_gid; /* Group ID of the file's group. */ - uint64_t st_rdev; /* Device number, if device. */ + abi_ullong st_rdev; /* Device number, if device. */ int64_t st_size; /* Size of file, in bytes. */ abi_ulong st_blksize; /* Optimal block size for I/O. */ abi_ulong __unused2; - uint64_t st_blocks; /* Number 512-byte blocks allocated. */ + abi_ullong st_blocks; /* Number 512-byte blocks allocated. */ abi_ulong target_st_atime; /* Time of last access. */ abi_ulong target_st_atime_nsec; abi_ulong target_st_mtime; /* Time of last modification. */ @@ -2097,14 +2097,14 @@ struct target_stat { #if !defined(TARGET_RISCV64) #define TARGET_HAS_STRUCT_STAT64 struct target_stat64 { - uint64_t st_dev; - uint64_t st_ino; + abi_ullong st_dev; + abi_ullong st_ino; unsigned int st_mode; unsigned int st_nlink; unsigned int st_uid; unsigned int st_gid; - uint64_t st_rdev; - uint64_t __pad1; + abi_ullong st_rdev; + abi_ullong __pad1; int64_t st_size; int st_blksize; int __pad2; @@ -2156,14 +2156,14 @@ struct target_stat { #define TARGET_HAS_STRUCT_STAT64 struct target_stat64 { - uint64_t st_dev; + abi_ullong st_dev; abi_uint _pad1; abi_uint _res1; abi_uint st_mode; abi_uint st_nlink; abi_uint st_uid; abi_uint st_gid; - uint64_t st_rdev; + abi_ullong st_rdev; abi_uint _pad2; int64_t st_size; abi_int st_blksize; @@ -2174,7 +2174,7 @@ struct target_stat64 { abi_uint target_st_mtime_nsec; abi_int target_st_ctime; abi_uint target_st_ctime_nsec; - uint64_t st_ino; + abi_ullong st_ino; }; #elif defined(TARGET_LOONGARCH64) @@ -2231,11 +2231,11 @@ struct target_statfs64 { abi_uint f_bsize; abi_uint f_frsize; /* Fragment size - unsupported */ abi_uint __pad; - uint64_t f_blocks; - uint64_t f_bfree; - uint64_t f_files; - uint64_t f_ffree; - uint64_t f_bavail; + abi_ullong f_blocks; + abi_ullong f_bfree; + abi_ullong f_files; + abi_ullong f_ffree; + abi_ullong f_bavail; target_fsid_t f_fsid; abi_uint f_namelen; abi_uint f_flags; @@ -2324,11 +2324,11 @@ struct target_statfs { struct target_statfs64 { abi_uint f_type; abi_uint f_bsize; - uint64_t f_blocks; - uint64_t f_bfree; - uint64_t f_bavail; - uint64_t f_files; - uint64_t f_ffree; + abi_ullong f_blocks; + abi_ullong f_bfree; + abi_ullong f_bavail; + abi_ullong f_files; + abi_ullong f_ffree; target_fsid_t f_fsid; abi_uint f_namelen; abi_uint f_frsize; @@ -2799,7 +2799,7 @@ struct target_statx { /* 0x00 */ abi_uint stx_mask; /* What results were written [uncond] */ abi_uint stx_blksize; /* Preferred general I/O size [uncond] */ - uint64_t stx_attributes; /* Flags conveying information about the file */ + abi_ullong stx_attributes; /* Flags conveying information about the file */ /* 0x10 */ abi_uint stx_nlink; /* Number of hard links */ abi_uint stx_uid; /* User ID of owner */ @@ -2807,10 +2807,10 @@ struct target_statx { uint16_t stx_mode; /* File mode */ uint16_t __spare0[1]; /* 0x20 */ - uint64_t stx_ino; /* Inode number */ - uint64_t stx_size; /* File size */ - uint64_t stx_blocks; /* Number of 512-byte blocks allocated */ - uint64_t stx_attributes_mask; /* Mask to show what is supported */ + abi_ullong stx_ino; /* Inode number */ + abi_ullong stx_size; /* File size */ + abi_ullong stx_blocks; /* Number of 512-byte blocks allocated */ + abi_ullong stx_attributes_mask; /* Mask to show what is supported */ /* 0x40 */ struct target_statx_timestamp stx_atime; /* Last access time */ struct target_statx_timestamp stx_btime; /* File creation time */ @@ -2822,7 +2822,7 @@ struct target_statx { abi_uint stx_dev_major; /* ID of device containing file [uncond] */ abi_uint stx_dev_minor; /* 0x90 */ - uint64_t __spare2[14]; /* Spare space for future expansion */ + abi_ullong __spare2[14]; /* Spare space for future expansion */ /* 0x100 */ }; From patchwork Sun Jul 9 18:28:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700857 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827374wrs; Sun, 9 Jul 2023 11:32:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlHS18J+PsX/LHZST3irUu6GiSlHp964dSrkbPcJ3vV/rt8eLwljCukouf4wI3kW7ie6AHV+ X-Received: by 2002:a05:622a:100c:b0:400:9847:5a04 with SMTP id d12-20020a05622a100c00b0040098475a04mr11758314qte.44.1688927521421; Sun, 09 Jul 2023 11:32:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927521; cv=none; d=google.com; s=arc-20160816; b=wQXwZzX2Rb2aB9OgcLGLdZmasVPuYJW172qQ1JZxSP9/Cs6iagYiajhvJX72mrgemF +Ynlx6B7WwPP0SSCfN7tnEAX6W7UgFFgbVkqjHZPpsUf+x3gvnahlVhdBflGk+Twyx0d rcV8O7XVg/6iTGIjsrPnFJKp7HL+44qqYiJuiC++tygtnIgXBzDMzD9gINPabIIdn+5M b3B976XWJP8Ug/SuGGTIdcbNLMYIHqc7Mbcc8+jmRJ3uIklTuYhW5W2au3rBzZWJI8SB xkPlXw8nCng3OQ6XvIM/uwfxBS5rQnb4L2FG/lXLGPfPiiogOop3OXZ1EIUClybfaaWY rHBg== 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:cc:to :from:dkim-signature; bh=IDhKHcH/mNT2yQDdOveHYCYG5DGoM6IQc0ARd1bSGIA=; fh=3IEiF/YPZ00TE94rna3Orj/L+TRFhpuNf7ElRJz3ubE=; b=unjdEBQtJnOjj2Sjgc+ujvioHbiHMKJ8k7cy1f+3dyUBmkkaDoNphvcTAG+7htkDqv b6HQRc3spiGxT5lwSvCIXLpvUHlfaidrsJ/wgKb39vVRcplLXnsdvxx2DBFwgq4W/RVE fhoKWLkinjme5rjEijOrIvTikDtuqruL+m6IXgIobWNsX/DFwLkY4Gy6lQZcYDcmohsQ pwMeB1KWoqlQWqILdEp+472IC8Lg+ayFMBIdSAsrc7h0jd1ZVVqHpoDo56iC8pY+w6Ds 8SOGM0Iai1WalvJ0wkZPwcPWO2zhNq+o6Vjh9cXrtmsgwz42K5GK11fCmpTkbhLI2jv1 o1dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TnEVosVy; 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 n3-20020ac85b43000000b003ff1fe3cd40si4944158qtw.162.2023.07.09.11.32.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:32:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TnEVosVy; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAW-0008Km-D9; Sun, 09 Jul 2023 14:30:00 -0400 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 1qIZAL-0008EV-MH for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:50 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAK-0000Ey-4E for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:49 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fbca8935bfso37951225e9.3 for ; Sun, 09 Jul 2023 11:29:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927386; x=1691519386; 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=IDhKHcH/mNT2yQDdOveHYCYG5DGoM6IQc0ARd1bSGIA=; b=TnEVosVyugd9dHHVAysxpaDfm1vWsUP8Z4gQzRDB9aTTEJnBEN+8vrGJEvk5W7x2TE QAcJ8TGT9pPxPYQv4Ly0u51XZL/OsTlgZJ3HNgm/RpfTEwDZ6pCkws6Mspcy9xZxiZGt /44g5Uoe1bB8NUmI8ZDQtQsTzIj4LbhGELyJuCnJ1hjViRIfAMQDHz37+0tEYVycBMn/ NQR9wt584vyue4CAvajnUL3qch9+c9eb9rz+S0VLamGq4KtRDi1nQa+LbuTy2iTBhAUt YI82y94HB/EadW1kbBlaDbytEC+SBEWhzwGqE+a9fP8O+qbB+VdkZgV7gTXtUCB9o3aJ St8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927386; x=1691519386; 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=IDhKHcH/mNT2yQDdOveHYCYG5DGoM6IQc0ARd1bSGIA=; b=JIYBOOkx2bhlwNQFmgCwPGcf6YC+Dl0n9FI+LKG+2y3oFJg3uB+cYeBzq+ErZssCtB 1utG3UFfiw5uQGgm2/HL2HSFACvbdqlp9Kc78XCqpmct6yTJBUg6qn01r2jNb4m/iN7i aIH6O0XNpXq69syqYreg+QriGJR103qnfzIExyYRncZ2Kv0FZ+1V5cBbB+0GIGd7sZ/q 8y/s0KlHBqSd622V01ZZ0+ViCiwVnqtyQjocj20tP9HAmU0Vc/nN+CV6FxaLhjDLkKno mrXOcwnFUp5KRsBEfKpFCnKJ60MKGwni1cmd3dz0+9l/d3N0GkkiTyWLeBcjSpcuD8UY Jrtw== X-Gm-Message-State: ABy/qLYXTprrsRJopc+LeWCvifx6ZShc1iBhq4vghXtO3311K28oBwca YVw7txjB8igec00Dyr/WAeZmEvAj9uzhxn/2J3gnqQ== X-Received: by 2002:a1c:f211:0:b0:3fc:5d2:9286 with SMTP id s17-20020a1cf211000000b003fc05d29286mr3368016wmc.2.1688927386707; Sun, 09 Jul 2023 11:29:46 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.29.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:29:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 06/45] linux-user: Use abi_llong not int64_t in syscall_defs.h Date: Sun, 9 Jul 2023 19:28:24 +0100 Message-Id: <20230709182934.309468-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32e.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Be careful not to change linux_dirent64, which is a host structure. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/syscall_defs.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 0af7249330..2846a8cfa5 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1455,8 +1455,8 @@ struct target_stat64 { unsigned char __pad2[6]; unsigned short st_rdev; - int64_t st_size; - int64_t st_blksize; + abi_llong st_size; + abi_llong st_blksize; unsigned char __pad4[4]; unsigned int st_blocks; @@ -1514,7 +1514,7 @@ struct target_stat64 { unsigned char __pad3[8]; - int64_t st_size; + abi_llong st_size; unsigned int st_blksize; unsigned char __pad4[8]; @@ -1630,10 +1630,10 @@ struct QEMU_PACKED target_stat64 { abi_ullong st_rdev; abi_ullong __pad1; - int64_t st_size; + abi_llong st_size; abi_int st_blksize; abi_uint __pad2; - int64_t st_blocks; /* Number 512-byte blocks allocated. */ + abi_llong st_blocks; int target_st_atime; unsigned int target_st_atime_nsec; @@ -1760,7 +1760,7 @@ struct target_stat { int st_gid; abi_ulong st_rdev; abi_ulong st_pad1[3]; /* Reserved for st_rdev expansion */ - int64_t st_size; + abi_llong st_size; abi_long target_st_atime; abi_ulong target_st_atime_nsec; /* Reserved for st_atime expansion */ abi_long target_st_mtime; @@ -1769,7 +1769,7 @@ struct target_stat { abi_ulong target_st_ctime_nsec; /* Reserved for st_ctime expansion */ abi_ulong st_blksize; abi_ulong st_pad2; - int64_t st_blocks; + abi_llong st_blocks; }; #elif defined(TARGET_ABI_MIPSO32) @@ -1824,7 +1824,7 @@ struct target_stat64 { abi_ulong st_rdev; abi_ulong st_pad1[3]; /* Reserved for st_rdev expansion */ - int64_t st_size; + abi_llong st_size; /* * Actually this should be timestruc_t st_atime, st_mtime and st_ctime @@ -1842,7 +1842,7 @@ struct target_stat64 { abi_ulong st_blksize; abi_ulong st_pad2; - int64_t st_blocks; + abi_llong st_blocks; }; #elif defined(TARGET_ALPHA) @@ -2051,7 +2051,7 @@ struct target_stat64 { unsigned int st_uid; /* User ID of the file's owner. */ unsigned int st_gid; /* Group ID of the file's group. */ abi_ullong st_rdev; /* Device number, if device. */ - int64_t st_size; /* Size of file, in bytes. */ + abi_llong st_size; /* Size of file, in bytes. */ abi_ulong st_blksize; /* Optimal block size for I/O. */ abi_ulong __unused2; abi_ullong st_blocks; /* Number 512-byte blocks allocated. */ @@ -2105,10 +2105,10 @@ struct target_stat64 { unsigned int st_gid; abi_ullong st_rdev; abi_ullong __pad1; - int64_t st_size; + abi_llong st_size; int st_blksize; int __pad2; - int64_t st_blocks; + abi_llong st_blocks; int target_st_atime; unsigned int target_st_atime_nsec; int target_st_mtime; @@ -2165,9 +2165,9 @@ struct target_stat64 { abi_uint st_gid; abi_ullong st_rdev; abi_uint _pad2; - int64_t st_size; + abi_llong st_size; abi_int st_blksize; - int64_t st_blocks; + abi_llong st_blocks; abi_int target_st_atime; abi_uint target_st_atime_nsec; abi_int target_st_mtime; @@ -2790,7 +2790,7 @@ struct target_user_cap_data { #define TARGET_SYSLOG_ACTION_SIZE_BUFFER 10 struct target_statx_timestamp { - int64_t tv_sec; + abi_llong tv_sec; abi_uint tv_nsec; abi_int __reserved; }; From patchwork Sun Jul 9 18:28:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700859 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827402wrs; Sun, 9 Jul 2023 11:32:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlFjU9cvVxOP8xEY19184aCPfG+oPy55g6U5iQeHYnPgpKiTIdW2Uc8LYeKa9iVEuY4CLJPf X-Received: by 2002:ac8:7f54:0:b0:403:691f:5403 with SMTP id g20-20020ac87f54000000b00403691f5403mr14285432qtk.67.1688927529022; Sun, 09 Jul 2023 11:32:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927529; cv=none; d=google.com; s=arc-20160816; b=RiUrlK3kNZTBIgI/8ocHJNPNhIIHf64wkd38llMjZAy+ny6d2gWG5upwie3fwzVLtl cQ6DEZZxxdurmlJTXQ+2p/gSGfkHQDz3Na0QlKtscJhlfM5fK2Xy4iYYTMEK2dzGvf24 k+Rou4iMF5qZm4G7T9C++nGBGiIJsr/1Kwp+/F+vuD5g7MtrZvq/TTsP6vJT6wf+McfE Ouo4Ved24/dmrmM+SPFhFYZUVTMXCqGxZwfdoUOoqiPpTbEwnyW5WBwV4XiMSrYCITUO 1u5rfAO7iErbV9V9NtViNJu8vyuGd8303UebZYdrsVkctEN4kVn+79lI0GasVJ8KhscX SPdg== 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:cc:to :from:dkim-signature; bh=WZowV46RDd4UZGFRJaWN3kYV5vNiK42zQttdiJYmLHk=; fh=4nfr0hkxlMpWE4oToQ1q4rzQVecv6te3cGVRc3YFjiI=; b=FCKnwToWQrm959GJZfUarlrcmPkB8dcNI/VSRcx7Ibe8Q3WZZyDuK3NO4ATfhbdg5F 2F2h/xN3EnP67xb0igIsjZFjfiPKLkeFIhfl7a4HqmR21/Ib629ysKMOsCCBCAioGkSz t8Dp8Vlc6auvaKaJIA/MqJouIFaBGontL98vw65WlW1vXfeUpj8+9z3HK63jWKjv6DmU GZf/WX/4wT5qxPG6M2hralqFvRlkSkR9OEl3AlbzUVU0MsWKNL8u1D7QX4alMcfN71yf ft+168Vbi2sQ25B2aZ4G/wdEsdadlqxjAYJSEfDvJgopEadLNXd6YPGxBpFLpt5EcAl/ j6lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MOvYnW5e; 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 v5-20020a05622a144500b003f9bd68a453si4747178qtx.791.2023.07.09.11.32.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:32:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MOvYnW5e; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAS-0008I4-Ft; Sun, 09 Jul 2023 14:29:56 -0400 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 1qIZAO-0008FL-H3 for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:52 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAL-0000Fo-TA for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:52 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fbf1b82d9cso39245025e9.2 for ; Sun, 09 Jul 2023 11:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927388; x=1691519388; 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=WZowV46RDd4UZGFRJaWN3kYV5vNiK42zQttdiJYmLHk=; b=MOvYnW5e1suGnFAHhS/xybBjtI5aw7Sqf74e8pT7LTfqjkEISNn4uMgXjWI+G0LrLZ BELzcneaIjZdRFAepURgVZhr9r2xBsFEVeD8F1/F0KsrseHvUWFRdjTOfqR8FM6rGDbe izNQYyRKYZOcTyUQecelp5rb2qs+Sv5xpCP7Pyy3ZyqoCSkopv8Nz/fhLzKTvYecp64r pX/LJYLpJUJ11ZZNeRh68gcBv2Q7+yyox1SrZHwBOy4oM0UJeqBg+uCqP9QX4Qu/2sl5 w6MrqiR6i0Omunfm4/jHeZ3SQXDGEWXGZ8cQ0TcDJKyVLSmEvF9VqK9/8TOUEqwvCayb KIQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927388; x=1691519388; 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=WZowV46RDd4UZGFRJaWN3kYV5vNiK42zQttdiJYmLHk=; b=AErLhq/mBKveKU5bmpS9uACIHa5PUfXWo43B94/Xo2TAqHgRieynI0Gzh4GbbWh/Ni +Dy3cgZSsJ+v0zmSC+FR7c2RE8KDLg5ZOlPSbUSZHx9TChdNV/Uq7EzPzqZmJ4tq65Wb qJDRrBrdoNMfeoYzM7beNgBwwa8RGc5mUyM/7UA5JI07coKoFKhUVRV2YEJ+1TI0jLSy tv/XhyLWhfe+fYHpFL/df/wc9cz03HRCsBIGJz+DaxrQiKmcRZBHN7KsDSCWNrPO3H24 yLHlU8mZljQec20p2NzO5/pjHHGdizBNp7oIdtmdct9+iAW5dXoiclVZalpna6ylzXKd ZmrA== X-Gm-Message-State: ABy/qLa37Efucfm4zyayJpjISKCd0fKXazzQqS2zbLn1v1L/oPuBh0Zp 4mHKEjKzEk1fjHtx+N+0Z7Vm5gKZKElq87aiVUwdyA== X-Received: by 2002:a1c:7904:0:b0:3fc:a8:dc3c with SMTP id l4-20020a1c7904000000b003fc00a8dc3cmr6258873wme.37.1688927388242; Sun, 09 Jul 2023 11:29:48 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.29.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:29:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH 07/45] linux-user: Use abi_uint not unsigned int in syscall_defs.h Date: Sun, 9 Jul 2023 19:28:26 +0100 Message-Id: <20230709182934.309468-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x331.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson --- linux-user/syscall_defs.h | 290 +++++++++++++++++++------------------- 1 file changed, 145 insertions(+), 145 deletions(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 2846a8cfa5..20986bd1d3 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -366,7 +366,7 @@ struct target_msghdr { abi_long msg_iovlen; /* Number of blocks */ abi_long msg_control; /* Per protocol magic (eg BSD file descriptor passing) */ abi_long msg_controllen; /* Length of cmsg list */ - unsigned int msg_flags; + abi_uint msg_flags; }; struct target_cmsghdr { @@ -403,7 +403,7 @@ __target_cmsg_nxthdr(struct target_msghdr *__mhdr, struct target_mmsghdr { struct target_msghdr msg_hdr; /* Message header */ - unsigned int msg_len; /* Number of bytes transmitted */ + abi_uint msg_len; /* Number of bytes transmitted */ }; struct target_rusage { @@ -595,8 +595,8 @@ typedef struct target_siginfo { /* POSIX.1b timers */ struct { - unsigned int _timer1; - unsigned int _timer2; + abi_uint _timer1; + abi_uint _timer2; } _timer; /* POSIX.1b signals */ @@ -857,10 +857,10 @@ struct target_rtc_pll_info { #define TARGET_TUNSETOWNER TARGET_IOW('T', 204, int) #define TARGET_TUNSETLINK TARGET_IOW('T', 205, int) #define TARGET_TUNSETGROUP TARGET_IOW('T', 206, int) -#define TARGET_TUNGETFEATURES TARGET_IOR('T', 207, unsigned int) -#define TARGET_TUNSETOFFLOAD TARGET_IOW('T', 208, unsigned int) -#define TARGET_TUNSETTXFILTER TARGET_IOW('T', 209, unsigned int) -#define TARGET_TUNGETIFF TARGET_IOR('T', 210, unsigned int) +#define TARGET_TUNGETFEATURES TARGET_IOR('T', 207, abi_uint) +#define TARGET_TUNSETOFFLOAD TARGET_IOW('T', 208, abi_uint) +#define TARGET_TUNSETTXFILTER TARGET_IOW('T', 209, abi_uint) +#define TARGET_TUNGETIFF TARGET_IOR('T', 210, abi_uint) #define TARGET_TUNGETSNDBUF TARGET_IOR('T', 211, int) #define TARGET_TUNSETSNDBUF TARGET_IOW('T', 212, int) /* @@ -870,7 +870,7 @@ struct target_rtc_pll_info { #define TARGET_TUNGETVNETHDRSZ TARGET_IOR('T', 215, int) #define TARGET_TUNSETVNETHDRSZ TARGET_IOW('T', 216, int) #define TARGET_TUNSETQUEUE TARGET_IOW('T', 217, int) -#define TARGET_TUNSETIFINDEX TARGET_IOW('T', 218, unsigned int) +#define TARGET_TUNSETIFINDEX TARGET_IOW('T', 218, abi_uint) /* TUNGETFILTER is not supported: see TUNATTACHFILTER. */ #define TARGET_TUNSETVNETLE TARGET_IOW('T', 220, int) #define TARGET_TUNGETVNETLE TARGET_IOR('T', 221, int) @@ -1361,8 +1361,8 @@ struct target_stat64 { #define TARGET_STAT64_HAS_BROKEN_ST_INO 1 abi_ulong __st_ino; - unsigned int st_mode; - unsigned int st_nlink; + abi_uint st_mode; + abi_uint st_nlink; abi_ulong st_uid; abi_ulong st_gid; @@ -1392,20 +1392,20 @@ struct target_stat64 { #define TARGET_HAS_STRUCT_STAT64 struct target_eabi_stat64 { unsigned long long st_dev; - unsigned int __pad1; + abi_uint __pad1; abi_ulong __st_ino; - unsigned int st_mode; - unsigned int st_nlink; + abi_uint st_mode; + abi_uint st_nlink; abi_ulong st_uid; abi_ulong st_gid; unsigned long long st_rdev; - unsigned int __pad2[2]; + abi_uint __pad2[2]; long long st_size; abi_ulong st_blksize; - unsigned int __pad3; + abi_uint __pad3; unsigned long long st_blocks; abi_ulong target_st_atime; @@ -1423,13 +1423,13 @@ struct target_eabi_stat64 { #elif defined(TARGET_SPARC64) && !defined(TARGET_ABI32) struct target_stat { - unsigned int st_dev; + abi_uint st_dev; abi_ulong st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned int st_uid; - unsigned int st_gid; - unsigned int st_rdev; + abi_uint st_mode; + abi_uint st_nlink; + abi_uint st_uid; + abi_uint st_gid; + abi_uint st_rdev; abi_long st_size; abi_long target_st_atime; abi_long target_st_mtime; @@ -1447,10 +1447,10 @@ struct target_stat64 { abi_ullong st_ino; abi_ullong st_nlink; - unsigned int st_mode; + abi_uint st_mode; - unsigned int st_uid; - unsigned int st_gid; + abi_uint st_uid; + abi_uint st_gid; unsigned char __pad2[6]; unsigned short st_rdev; @@ -1459,7 +1459,7 @@ struct target_stat64 { abi_llong st_blksize; unsigned char __pad4[4]; - unsigned int st_blocks; + abi_uint st_blocks; abi_ulong target_st_atime; abi_ulong target_st_atime_nsec; @@ -1503,11 +1503,11 @@ struct target_stat64 { abi_ullong st_ino; - unsigned int st_mode; - unsigned int st_nlink; + abi_uint st_mode; + abi_uint st_nlink; - unsigned int st_uid; - unsigned int st_gid; + abi_uint st_uid; + abi_uint st_gid; unsigned char __pad2[6]; unsigned short st_rdev; @@ -1515,22 +1515,22 @@ struct target_stat64 { unsigned char __pad3[8]; abi_llong st_size; - unsigned int st_blksize; + abi_uint st_blksize; unsigned char __pad4[8]; - unsigned int st_blocks; + abi_uint st_blocks; - unsigned int target_st_atime; - unsigned int target_st_atime_nsec; + abi_uint target_st_atime; + abi_uint target_st_atime_nsec; - unsigned int target_st_mtime; - unsigned int target_st_mtime_nsec; + abi_uint target_st_mtime; + abi_uint target_st_mtime_nsec; - unsigned int target_st_ctime; - unsigned int target_st_ctime_nsec; + abi_uint target_st_ctime; + abi_uint target_st_ctime_nsec; - unsigned int __unused1; - unsigned int __unused2; + abi_uint __unused1; + abi_uint __unused2; }; #elif defined(TARGET_PPC) @@ -1541,13 +1541,13 @@ struct target_stat { abi_ulong st_ino; #if defined(TARGET_PPC64) abi_ulong st_nlink; - unsigned int st_mode; + abi_uint st_mode; #else - unsigned int st_mode; + abi_uint st_mode; unsigned short st_nlink; #endif - unsigned int st_uid; - unsigned int st_gid; + abi_uint st_uid; + abi_uint st_gid; abi_ulong st_rdev; abi_ulong st_size; abi_ulong st_blksize; @@ -1570,24 +1570,24 @@ struct target_stat { struct QEMU_PACKED target_stat64 { unsigned long long st_dev; unsigned long long st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned int st_uid; - unsigned int st_gid; + abi_uint st_mode; + abi_uint st_nlink; + abi_uint st_uid; + abi_uint st_gid; unsigned long long st_rdev; unsigned long long __pad0; long long st_size; int st_blksize; - unsigned int __pad1; + abi_uint __pad1; long long st_blocks; /* Number 512-byte blocks allocated. */ int target_st_atime; - unsigned int target_st_atime_nsec; + abi_uint target_st_atime_nsec; int target_st_mtime; - unsigned int target_st_mtime_nsec; + abi_uint target_st_mtime_nsec; int target_st_ctime; - unsigned int target_st_ctime_nsec; - unsigned int __unused4; - unsigned int __unused5; + abi_uint target_st_ctime_nsec; + abi_uint __unused4; + abi_uint __unused5; }; #endif @@ -1597,10 +1597,10 @@ struct QEMU_PACKED target_stat64 { struct target_stat { abi_ulong st_dev; abi_ulong st_ino; - unsigned int st_mode; + abi_uint st_mode; unsigned short st_nlink; - unsigned int st_uid; - unsigned int st_gid; + abi_uint st_uid; + abi_uint st_gid; abi_ulong st_rdev; abi_ulong st_size; abi_ulong st_blksize; @@ -1636,11 +1636,11 @@ struct QEMU_PACKED target_stat64 { abi_llong st_blocks; int target_st_atime; - unsigned int target_st_atime_nsec; + abi_uint target_st_atime_nsec; int target_st_mtime; - unsigned int target_st_mtime_nsec; + abi_uint target_st_mtime_nsec; int target_st_ctime; - unsigned int target_st_ctime_nsec; + abi_uint target_st_ctime_nsec; abi_ullong st_ino; }; @@ -1680,8 +1680,8 @@ struct target_stat64 { #define TARGET_STAT64_HAS_BROKEN_ST_INO 1 abi_ulong __st_ino; - unsigned int st_mode; - unsigned int st_nlink; + abi_uint st_mode; + abi_uint st_nlink; abi_ulong st_uid; abi_ulong st_gid; @@ -1712,19 +1712,19 @@ struct target_stat64 { #define TARGET_STAT_HAVE_NSEC /* The memory layout is the same as of struct stat64 of the 32-bit kernel. */ struct target_stat { - unsigned int st_dev; - unsigned int st_pad0[3]; /* Reserved for st_dev expansion */ + abi_uint st_dev; + abi_uint st_pad0[3]; /* Reserved for st_dev expansion */ abi_ulong st_ino; - unsigned int st_mode; - unsigned int st_nlink; + abi_uint st_mode; + abi_uint st_nlink; int st_uid; int st_gid; - unsigned int st_rdev; - unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */ + abi_uint st_rdev; + abi_uint st_pad1[3]; /* Reserved for st_rdev expansion */ abi_ulong st_size; @@ -1732,17 +1732,17 @@ struct target_stat { * Actually this should be timestruc_t st_atime, st_mtime and st_ctime * but we don't have it under Linux. */ - unsigned int target_st_atime; - unsigned int target_st_atime_nsec; + abi_uint target_st_atime; + abi_uint target_st_atime_nsec; - unsigned int target_st_mtime; - unsigned int target_st_mtime_nsec; + abi_uint target_st_mtime; + abi_uint target_st_mtime_nsec; - unsigned int target_st_ctime; - unsigned int target_st_ctime_nsec; + abi_uint target_st_ctime; + abi_uint target_st_ctime_nsec; - unsigned int st_blksize; - unsigned int st_pad2; + abi_uint st_blksize; + abi_uint st_pad2; abi_ulong st_blocks; }; @@ -1754,8 +1754,8 @@ struct target_stat { abi_ulong st_dev; abi_ulong st_pad0[3]; /* Reserved for st_dev expansion */ abi_ullong st_ino; - unsigned int st_mode; - unsigned int st_nlink; + abi_uint st_mode; + abi_uint st_nlink; int st_uid; int st_gid; abi_ulong st_rdev; @@ -1779,8 +1779,8 @@ struct target_stat { unsigned st_dev; abi_long st_pad1[3]; /* Reserved for network id */ abi_ulong st_ino; - unsigned int st_mode; - unsigned int st_nlink; + abi_uint st_mode; + abi_uint st_nlink; int st_uid; int st_gid; unsigned st_rdev; @@ -1815,8 +1815,8 @@ struct target_stat64 { abi_ullong st_ino; - unsigned int st_mode; - unsigned int st_nlink; + abi_uint st_mode; + abi_uint st_nlink; int st_uid; int st_gid; @@ -1848,21 +1848,21 @@ struct target_stat64 { #elif defined(TARGET_ALPHA) struct target_stat { - unsigned int st_dev; - unsigned int st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned int st_uid; - unsigned int st_gid; - unsigned int st_rdev; + abi_uint st_dev; + abi_uint st_ino; + abi_uint st_mode; + abi_uint st_nlink; + abi_uint st_uid; + abi_uint st_gid; + abi_uint st_rdev; abi_long st_size; abi_ulong target_st_atime; abi_ulong target_st_mtime; abi_ulong target_st_ctime; - unsigned int st_blksize; - unsigned int st_blocks; - unsigned int st_flags; - unsigned int st_gen; + abi_uint st_blksize; + abi_uint st_blocks; + abi_uint st_flags; + abi_uint st_gen; }; #define TARGET_HAS_STRUCT_STAT64 @@ -1873,12 +1873,12 @@ struct target_stat64 { abi_long st_size; abi_ulong st_blocks; - unsigned int st_mode; - unsigned int st_uid; - unsigned int st_gid; - unsigned int st_blksize; - unsigned int st_nlink; - unsigned int __pad0; + abi_uint st_mode; + abi_uint st_uid; + abi_uint st_gid; + abi_uint st_blksize; + abi_uint st_nlink; + abi_uint __pad0; abi_ulong target_st_atime; abi_ulong target_st_atime_nsec; @@ -1924,8 +1924,8 @@ struct QEMU_PACKED target_stat64 { #define TARGET_STAT64_HAS_BROKEN_ST_INO 1 abi_ulong __st_ino; - unsigned int st_mode; - unsigned int st_nlink; + abi_uint st_mode; + abi_uint st_nlink; abi_ulong st_uid; abi_ulong st_gid; @@ -1957,10 +1957,10 @@ struct target_stat { abi_ulong st_ino; abi_ulong st_nlink; - unsigned int st_mode; - unsigned int st_uid; - unsigned int st_gid; - unsigned int __pad0; + abi_uint st_mode; + abi_uint st_uid; + abi_uint st_gid; + abi_uint __pad0; abi_ulong st_rdev; abi_long st_size; abi_long st_blksize; @@ -1980,10 +1980,10 @@ struct target_stat { abi_ulong st_dev; abi_ulong st_ino; abi_ulong st_nlink; - unsigned int st_mode; - unsigned int st_uid; - unsigned int st_gid; - unsigned int __pad1; + abi_uint st_mode; + abi_uint st_uid; + abi_uint st_gid; + abi_uint __pad1; abi_ulong st_rdev; abi_ulong st_size; abi_ulong target_st_atime; @@ -2001,10 +2001,10 @@ struct target_stat { struct target_stat { abi_ulong st_dev; abi_ulong st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned int st_uid; - unsigned int st_gid; + abi_uint st_mode; + abi_uint st_nlink; + abi_uint st_uid; + abi_uint st_gid; abi_ulong st_rdev; abi_ulong _pad1; abi_long st_size; @@ -2017,17 +2017,17 @@ struct target_stat { abi_ulong target_st_mtime_nsec; abi_long target_st_ctime; abi_ulong target_st_ctime_nsec; - unsigned int __unused[2]; + abi_uint __unused[2]; }; #elif defined(TARGET_XTENSA) #define TARGET_STAT_HAVE_NSEC struct target_stat { abi_ulong st_dev; abi_ulong st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned int st_uid; - unsigned int st_gid; + abi_uint st_mode; + abi_uint st_nlink; + abi_uint st_uid; + abi_uint st_gid; abi_ulong st_rdev; abi_long st_size; abi_ulong st_blksize; @@ -2046,10 +2046,10 @@ struct target_stat { struct target_stat64 { abi_ullong st_dev; /* Device */ abi_ullong st_ino; /* File serial number */ - unsigned int st_mode; /* File mode. */ - unsigned int st_nlink; /* Link count. */ - unsigned int st_uid; /* User ID of the file's owner. */ - unsigned int st_gid; /* Group ID of the file's group. */ + abi_uint st_mode; /* File mode. */ + abi_uint st_nlink; /* Link count. */ + abi_uint st_uid; /* User ID of the file's owner. */ + abi_uint st_gid; /* Group ID of the file's group. */ abi_ullong st_rdev; /* Device number, if device. */ abi_llong st_size; /* Size of file, in bytes. */ abi_ulong st_blksize; /* Optimal block size for I/O. */ @@ -2074,10 +2074,10 @@ struct target_stat64 { struct target_stat { abi_ulong st_dev; abi_ulong st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned int st_uid; - unsigned int st_gid; + abi_uint st_mode; + abi_uint st_nlink; + abi_uint st_uid; + abi_uint st_gid; abi_ulong st_rdev; abi_ulong __pad1; abi_long st_size; @@ -2090,8 +2090,8 @@ struct target_stat { abi_ulong target_st_mtime_nsec; abi_long target_st_ctime; abi_ulong target_st_ctime_nsec; - unsigned int __unused4; - unsigned int __unused5; + abi_uint __unused4; + abi_uint __unused5; }; #if !defined(TARGET_RISCV64) @@ -2099,10 +2099,10 @@ struct target_stat { struct target_stat64 { abi_ullong st_dev; abi_ullong st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned int st_uid; - unsigned int st_gid; + abi_uint st_mode; + abi_uint st_nlink; + abi_uint st_uid; + abi_uint st_gid; abi_ullong st_rdev; abi_ullong __pad1; abi_llong st_size; @@ -2110,13 +2110,13 @@ struct target_stat64 { int __pad2; abi_llong st_blocks; int target_st_atime; - unsigned int target_st_atime_nsec; + abi_uint target_st_atime_nsec; int target_st_mtime; - unsigned int target_st_mtime_nsec; + abi_uint target_st_mtime_nsec; int target_st_ctime; - unsigned int target_st_ctime_nsec; - unsigned int __unused4; - unsigned int __unused5; + abi_uint target_st_ctime_nsec; + abi_uint __unused4; + abi_uint __unused5; }; #endif @@ -2498,7 +2498,7 @@ struct target_snd_timer_id { struct target_snd_timer_ginfo { struct target_snd_timer_id tid; - unsigned int flags; + abi_uint flags; int card; unsigned char id[64]; unsigned char name[80]; @@ -2506,7 +2506,7 @@ struct target_snd_timer_ginfo { abi_ulong resolution; abi_ulong resolution_min; abi_ulong resolution_max; - unsigned int clients; + abi_uint clients; unsigned char reserved[32]; }; @@ -2531,7 +2531,7 @@ struct target_snd_timer_select { }; struct target_snd_timer_info { - unsigned int flags; + abi_uint flags; int card; unsigned char id[64]; unsigned char name[80]; @@ -2542,10 +2542,10 @@ struct target_snd_timer_info { struct target_snd_timer_status { struct target_timespec tstamp; - unsigned int resolution; - unsigned int lost; - unsigned int overrun; - unsigned int queue; + abi_uint resolution; + abi_uint lost; + abi_uint overrun; + abi_uint queue; unsigned char reserved[64]; }; @@ -2623,7 +2623,7 @@ struct target_sysinfo { unsigned short pad; /* explicit padding for m68k */ abi_ulong totalhigh; /* Total high memory size */ abi_ulong freehigh; /* Available high memory size */ - unsigned int mem_unit; /* Memory unit size in bytes */ + abi_uint mem_unit; /* Memory unit size in bytes */ char _f[20-2*sizeof(abi_long)-sizeof(int)]; /* Padding: libc5 uses this.. */ }; From patchwork Sun Jul 9 18:28:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700853 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827112wrs; Sun, 9 Jul 2023 11:31:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlFMtR9082ZXHMbbdpH0ao90Pstu9cNQ4pYbAO0X9LvU3Q4+5EdjaKmIe1J9UbOJeVQdd5Be X-Received: by 2002:a05:620a:29c1:b0:765:ad54:d934 with SMTP id s1-20020a05620a29c100b00765ad54d934mr10939414qkp.2.1688927469073; Sun, 09 Jul 2023 11:31:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927469; cv=none; d=google.com; s=arc-20160816; b=FjRtQnZruNaZkePXMWHROYKnO5B72WhSoOJwjMCJR05m9b0l1b3KDQN55y5pO3Pv6G YjUelO4M/26vkhYvQsrTSi01OxILQiRgA0frVX8Rgwje6AyaTk1TFx9mAS4I6UDNqq3F yFsJupxkqDNbbdoK+2IHziETd2F2R1E0ImpON3Xa1Ya0yMlZrD32WbwE2zdweEDE+euT F2mG7WmoS5jAmYuJiR3anOo/P+2wU/aomZ7wDFeU2vWKkywrbjGH5uhIkXFd6pBvLnWx fiL5GVHBO+ULcllDLA2pw4w7tdvUM/D81Lkd7NiEQwLsDNCsYbIG9LuDW9n28S/eP+t/ YFxQ== 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:cc:to :from:dkim-signature; bh=1lNVmzIrZ20vaRM4z3bBKO9neuQ8i1reH4ftvygdvPI=; fh=5s19N4v2JlXpEkFgkc3sswK3fL8V2plB1o7R02nrQbs=; b=TqyXcdu6/5yM44UwoG8r1XGk3qAfhGr+OLZkTQu9RBpHds1v7mjQpW0Ogi2kMjh2TA qlFiMiw6q8aortjagB2RWX+OKalORYpYhqHHzTQnU4i82wotQ3DXhMJDBtl/Zwi5QVYi M5VwNBR5le6AzsmW5aKO3sJcZ0WvV9v+HzGAIwJHW9wEZXjKDpsZAy/lcYEkiU2EEo+n 9vzg8t0ZCmHDv3Pt0Ch+v0p6ajBYIhUn772A47WFEgxS0bTc230bG5DCKOx0GRrQp7nO H2eIdGleaOwbzzOUNRu6Yl42jvECxsPzFJkI7UQ3MKlsnp/38asYRr+i5h3vvS/RDUSe xEqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hwKhR2u4; 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-20020ae9ec16000000b00767162395fdsi4970107qkg.635.2023.07.09.11.31.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:31:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hwKhR2u4; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAU-0008JI-L4; Sun, 09 Jul 2023 14:29:58 -0400 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 1qIZAO-0008FD-Cf for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:52 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAM-0000GJ-PB for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:52 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-313fb7f0f80so3703647f8f.2 for ; Sun, 09 Jul 2023 11:29:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927389; x=1691519389; 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=1lNVmzIrZ20vaRM4z3bBKO9neuQ8i1reH4ftvygdvPI=; b=hwKhR2u4ZPO+LHJAJwZIEUHdQcXLyQZCxBfL5arSBucmL5FRyxbLxE8zZrU/xXuSpR 7Woiyhizdydk8HVElaquorPk7tAoOyERKEwIzaGXLP/HEXbzA2GoqbIECRIppG5AY1Lt BF5g+Z+gX/B1QNqHGBW4Z3RcDKOX2uni3BlzPxL0rKziybtjIjInruP1PGyq3GL3G+uA uYE4s0J+yx15y37a63NmbedeuiKYOXz8YJU7JDJXcBNegvjuf/tMqWfLp4JlZuxa1eM7 GWWVQi2uzvcQ7qAW1JFVUAIftPGGfQHv0eE9CygKystNLXVkVCOL8JoxR7zqeBcMxqX/ v7vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927389; x=1691519389; 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=1lNVmzIrZ20vaRM4z3bBKO9neuQ8i1reH4ftvygdvPI=; b=dcJapRDLqhx06S/DWMPzUFnkkvkbp0JrL7W2SVVDMLYINW4GCoDUGjsYJuRC0G9Rl5 rFGqDtnMcZDiG7VVinHqg7QaqTDPiYXl5ZBgi8Uw7RRwovVcOPuBKlINeoUnWAK+laLU da1xXSgGzSQLWgJmP1aLEUMUXL7r6QaTDhGWDiv6iwwIBBfIfoupSAG50izNS+QZ/8my nGv5lY3iT0/YNAXR9G3quowQ73b31akAK8R0gIz8qsr4ZGlpSgVmLTvSxIC4RjlcMNRS QLTwFaWT6/LD5ACIJBKwz9oa+9AOzlmSVzEipp15AQBjUAsHObpJub5IJZMxnQLc4kZ4 27lw== X-Gm-Message-State: ABy/qLYv2aIA4BCD7CiLj36/xIUHj5ZJ7fDWjHRd7kTgQBu0SGVrlsvo AsLR3Y5ZhLOvkIIVyaA72A3/ioloFEaHjdKHAA6x0w== X-Received: by 2002:adf:eb09:0:b0:314:4914:3421 with SMTP id s9-20020adfeb09000000b0031449143421mr8296836wrn.12.1688927389094; Sun, 09 Jul 2023 11:29:49 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.29.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:29:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= Subject: [PULL 08/37] crypto: Add aesdec_IMC Date: Sun, 9 Jul 2023 19:28:27 +0100 Message-Id: <20230709182934.309468-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42a.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Add a primitive for InvMixColumns. Acked-by: Daniel P. Berrangé Signed-off-by: Richard Henderson --- host/include/generic/host/crypto/aes-round.h | 2 + include/crypto/aes-round.h | 18 ++++++ crypto/aes.c | 59 ++++++++++++++++++++ 3 files changed, 79 insertions(+) diff --git a/host/include/generic/host/crypto/aes-round.h b/host/include/generic/host/crypto/aes-round.h index 1b82afc629..335ec3f11e 100644 --- a/host/include/generic/host/crypto/aes-round.h +++ b/host/include/generic/host/crypto/aes-round.h @@ -15,6 +15,8 @@ void aesenc_SB_SR_AK_accel(AESState *, const AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); +void aesdec_IMC_accel(AESState *, const AESState *, bool) + QEMU_ERROR("unsupported accel"); void aesdec_ISB_ISR_AK_accel(AESState *, const AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); diff --git a/include/crypto/aes-round.h b/include/crypto/aes-round.h index 7d2be40a67..7be2cc0d8e 100644 --- a/include/crypto/aes-round.h +++ b/include/crypto/aes-round.h @@ -59,6 +59,24 @@ static inline void aesenc_SB_SR_AK(AESState *r, const AESState *st, } } +/* + * Perform InvMixColumns. + */ + +void aesdec_IMC_gen(AESState *ret, const AESState *st); +void aesdec_IMC_genrev(AESState *ret, const AESState *st); + +static inline void aesdec_IMC(AESState *r, const AESState *st, bool be) +{ + if (HAVE_AES_ACCEL) { + aesdec_IMC_accel(r, st, be); + } else if (HOST_BIG_ENDIAN == be) { + aesdec_IMC_gen(r, st); + } else { + aesdec_IMC_genrev(r, st); + } +} + /* * Perform InvSubBytes + InvShiftRows + AddRoundKey. */ diff --git a/crypto/aes.c b/crypto/aes.c index ec300cda0c..6c05d731f4 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -1322,6 +1322,65 @@ void aesenc_SB_SR_AK_genrev(AESState *r, const AESState *s, const AESState *k) aesenc_SB_SR_AK_swap(r, s, k, true); } +/* + * Perform InvMixColumns. + */ +static inline void +aesdec_IMC_swap(AESState *r, const AESState *st, bool swap) +{ + int swap_b = swap * 0xf; + int swap_w = swap * 0x3; + bool be = HOST_BIG_ENDIAN ^ swap; + uint32_t t; + + /* Note that AES_imc is encoded for big-endian. */ + t = (AES_imc[st->b[swap_b ^ 0x0]][0] ^ + AES_imc[st->b[swap_b ^ 0x1]][1] ^ + AES_imc[st->b[swap_b ^ 0x2]][2] ^ + AES_imc[st->b[swap_b ^ 0x3]][3]); + if (!be) { + t = bswap32(t); + } + r->w[swap_w ^ 0] = t; + + t = (AES_imc[st->b[swap_b ^ 0x4]][0] ^ + AES_imc[st->b[swap_b ^ 0x5]][1] ^ + AES_imc[st->b[swap_b ^ 0x6]][2] ^ + AES_imc[st->b[swap_b ^ 0x7]][3]); + if (!be) { + t = bswap32(t); + } + r->w[swap_w ^ 1] = t; + + t = (AES_imc[st->b[swap_b ^ 0x8]][0] ^ + AES_imc[st->b[swap_b ^ 0x9]][1] ^ + AES_imc[st->b[swap_b ^ 0xA]][2] ^ + AES_imc[st->b[swap_b ^ 0xB]][3]); + if (!be) { + t = bswap32(t); + } + r->w[swap_w ^ 2] = t; + + t = (AES_imc[st->b[swap_b ^ 0xC]][0] ^ + AES_imc[st->b[swap_b ^ 0xD]][1] ^ + AES_imc[st->b[swap_b ^ 0xE]][2] ^ + AES_imc[st->b[swap_b ^ 0xF]][3]); + if (!be) { + t = bswap32(t); + } + r->w[swap_w ^ 3] = t; +} + +void aesdec_IMC_gen(AESState *r, const AESState *st) +{ + aesdec_IMC_swap(r, st, false); +} + +void aesdec_IMC_genrev(AESState *r, const AESState *st) +{ + aesdec_IMC_swap(r, st, true); +} + /* * Perform InvSubBytes + InvShiftRows + AddRoundKey. */ From patchwork Sun Jul 9 18:28:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700870 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827873wrs; Sun, 9 Jul 2023 11:33:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlGyQqyC9w9Olhzbyi8BmtkHqLe9vwmFbnniCnt+8xdFqbkovSL9eWYe9S6pqFNJ1jJKqJfV X-Received: by 2002:a05:620a:4487:b0:763:9980:c895 with SMTP id x7-20020a05620a448700b007639980c895mr13056475qkp.70.1688927627895; Sun, 09 Jul 2023 11:33:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927627; cv=none; d=google.com; s=arc-20160816; b=KWfLL1T+si1YLI5Mg13U8aHudpemkuwWLxgakzEZYW8W0HqNMS5cBVapWCldv9UtjM bGdqSaWOUaK4CyIap5wpl3ZlOrHojy+9xK7zMJOQ1e2qOn2u+EEJ6JU7tmaz7HCzaFc9 ekDlNaBoelWdPUI9rRoXmpl6fXC6aYzTf6SqB4FNX5XQCn2f41bHebFjg9kWRx2wXQh8 2JvseU/9QKtdC5KkZaWiTANucJv1JTecfeSzy38tR0URC4N3JYjWqFIf8Rscm8kyesGV 97pGPNAmaS2ETFHp/DA+Hk+9q8oe3cpZ9N0F/KX7j5tfYxgs19/d0UKGhKHVlSDcu/zW a49g== 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:cc:to :from:dkim-signature; bh=ne/prNzqsLfpjp4V0V8cndvcCHzJQtvFp1sqS4i2NnA=; fh=5s19N4v2JlXpEkFgkc3sswK3fL8V2plB1o7R02nrQbs=; b=PtIEszKrZFuAgvUVW+W04/cjqjM6n/jbwNt12ZkMIK6Pd9Dmzgh0LdegabUKwa0QKC sgCts7o82g8lQL8dwDCES/LtVKxyauEMWcgk9UCQsXj97ieIA3We9uOzvfC46MYPi5UU PNx6DR+jyF5wB1qw2kDRC6TsoEOHtPIudYX8dmdLohiIVzts/FyzwSmAeXXmo91ZynGn 5UTq3iJcdHm7UDpqv+u/kQ7aNM8jpGKhwowpCtoywFV3WBwpieJmdnefbpasIiLQTC6Y tyYi53bt3HPubQmHVcqZHSJ/7BoqQuz9H+ZDArzg0XqUYGIOUjISPf2LD/Hs+bXfAGkM gf4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UenPH1rM; 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 cx21-20020a05620a51d500b0076640b7518bsi5018876qkb.765.2023.07.09.11.33.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:33:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UenPH1rM; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAW-0008KS-0P; Sun, 09 Jul 2023 14:30:00 -0400 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 1qIZAQ-0008Gf-Gx for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:54 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAO-0000Gn-PG for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:54 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fbc0609cd6so37233505e9.1 for ; Sun, 09 Jul 2023 11:29:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927391; x=1691519391; 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=ne/prNzqsLfpjp4V0V8cndvcCHzJQtvFp1sqS4i2NnA=; b=UenPH1rMrHzbXae5oZydAy4inhsvKksXnkCNF/s5omq4pjjAof0Q1Y34AzGSX+eKaz zqdcb6vtF9y1nzZazlO76sRK9Rf/0sLJrytwFGAVsia0/D/m0dRx/uYdVS6Z6SZzixAi 9lOOBTVeS1XZK/L5fAdx8eF9bZJaU/1mbFYYc3BmCaHcvffchheFGZtnSH2K7BU9nZoH LFTZIrNafWPmFIBD89FCj98jKz8rqxmBNH127xwVjIwqJCIZ9eVPCJtkNQxk3lrnraFC GvFb+ZQYpJMZt01PZmPeHsp4OR932CVavMpObyh0/652BvBK/6KB7Sm66Lhs3wx3jH4w nhcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927391; x=1691519391; 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=ne/prNzqsLfpjp4V0V8cndvcCHzJQtvFp1sqS4i2NnA=; b=h8oIGowUsafbmFXHEjp9csv8gaoXUowOJfqVodrQMd7mDOCQ8pVol3x7T5uNIFDt+f g00nB3QQ9iKsUIHUfxOMcKEe0nfkZzwgfuSJbzlui/dNy482j2qxIwoTpH1nVlaJ4njQ jQX9NTbWUCl3Xfqqb597iAKSNR3rHpGc37L7t8OIRjADsq2woEkNIRrFX2OttDfuXAKA 4d+dX/zPxxwhnnf49zN4wWCoSWSwW4lMj1ohWxpTSimEjE5kik+i3JAsJSlzpOQF2P2o 661xxQ0pvqHdSFgAZV1EYMoOOgZEKD3r99nCRUsuzuYk6CX08JDuGvMfNPQb+8p5n2xj 3rOw== X-Gm-Message-State: ABy/qLY8//Fbd4ATTvU1kwPIuTBZozahuOJLwL840QpYlHRIgk1TZzqd Nq9eqdKZmdd0d2HlhD6sFrIWMSA9kfI6Rn99YjQuNw== X-Received: by 2002:a05:600c:22c1:b0:3f7:f45d:5e44 with SMTP id 1-20020a05600c22c100b003f7f45d5e44mr8188722wmg.32.1688927391250; Sun, 09 Jul 2023 11:29:51 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.29.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:29:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= Subject: [PULL 09/37] crypto: Add aesenc_SB_SR_MC_AK Date: Sun, 9 Jul 2023 19:28:29 +0100 Message-Id: <20230709182934.309468-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x336.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Add a primitive for SubBytes + ShiftRows + MixColumns + AddRoundKey. Acked-by: Daniel P. Berrangé Signed-off-by: Richard Henderson --- host/include/generic/host/crypto/aes-round.h | 3 + include/crypto/aes-round.h | 21 +++++++ crypto/aes.c | 58 ++++++++++++++++++++ 3 files changed, 82 insertions(+) diff --git a/host/include/generic/host/crypto/aes-round.h b/host/include/generic/host/crypto/aes-round.h index 335ec3f11e..9886e81e50 100644 --- a/host/include/generic/host/crypto/aes-round.h +++ b/host/include/generic/host/crypto/aes-round.h @@ -14,6 +14,9 @@ void aesenc_MC_accel(AESState *, const AESState *, bool) void aesenc_SB_SR_AK_accel(AESState *, const AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); +void aesenc_SB_SR_MC_AK_accel(AESState *, const AESState *, + const AESState *, bool) + QEMU_ERROR("unsupported accel"); void aesdec_IMC_accel(AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); diff --git a/include/crypto/aes-round.h b/include/crypto/aes-round.h index 7be2cc0d8e..03688c8640 100644 --- a/include/crypto/aes-round.h +++ b/include/crypto/aes-round.h @@ -59,6 +59,27 @@ static inline void aesenc_SB_SR_AK(AESState *r, const AESState *st, } } +/* + * Perform SubBytes + ShiftRows + MixColumns + AddRoundKey. + */ + +void aesenc_SB_SR_MC_AK_gen(AESState *ret, const AESState *st, + const AESState *rk); +void aesenc_SB_SR_MC_AK_genrev(AESState *ret, const AESState *st, + const AESState *rk); + +static inline void aesenc_SB_SR_MC_AK(AESState *r, const AESState *st, + const AESState *rk, bool be) +{ + if (HAVE_AES_ACCEL) { + aesenc_SB_SR_MC_AK_accel(r, st, rk, be); + } else if (HOST_BIG_ENDIAN == be) { + aesenc_SB_SR_MC_AK_gen(r, st, rk); + } else { + aesenc_SB_SR_MC_AK_genrev(r, st, rk); + } +} + /* * Perform InvMixColumns. */ diff --git a/crypto/aes.c b/crypto/aes.c index 6c05d731f4..a193d98d54 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -1322,6 +1322,64 @@ void aesenc_SB_SR_AK_genrev(AESState *r, const AESState *s, const AESState *k) aesenc_SB_SR_AK_swap(r, s, k, true); } +/* + * Perform SubBytes + ShiftRows + MixColumns + AddRoundKey. + */ +static inline void +aesenc_SB_SR_MC_AK_swap(AESState *r, const AESState *st, + const AESState *rk, bool swap) +{ + int swap_b = swap * 0xf; + int swap_w = swap * 0x3; + bool be = HOST_BIG_ENDIAN ^ swap; + uint32_t w0, w1, w2, w3; + + w0 = (AES_Te0[st->b[swap_b ^ AES_SH(0x0)]] ^ + AES_Te1[st->b[swap_b ^ AES_SH(0x1)]] ^ + AES_Te2[st->b[swap_b ^ AES_SH(0x2)]] ^ + AES_Te3[st->b[swap_b ^ AES_SH(0x3)]]); + + w1 = (AES_Te0[st->b[swap_b ^ AES_SH(0x4)]] ^ + AES_Te1[st->b[swap_b ^ AES_SH(0x5)]] ^ + AES_Te2[st->b[swap_b ^ AES_SH(0x6)]] ^ + AES_Te3[st->b[swap_b ^ AES_SH(0x7)]]); + + w2 = (AES_Te0[st->b[swap_b ^ AES_SH(0x8)]] ^ + AES_Te1[st->b[swap_b ^ AES_SH(0x9)]] ^ + AES_Te2[st->b[swap_b ^ AES_SH(0xA)]] ^ + AES_Te3[st->b[swap_b ^ AES_SH(0xB)]]); + + w3 = (AES_Te0[st->b[swap_b ^ AES_SH(0xC)]] ^ + AES_Te1[st->b[swap_b ^ AES_SH(0xD)]] ^ + AES_Te2[st->b[swap_b ^ AES_SH(0xE)]] ^ + AES_Te3[st->b[swap_b ^ AES_SH(0xF)]]); + + /* Note that AES_TeX is encoded for big-endian. */ + if (!be) { + w0 = bswap32(w0); + w1 = bswap32(w1); + w2 = bswap32(w2); + w3 = bswap32(w3); + } + + r->w[swap_w ^ 0] = rk->w[swap_w ^ 0] ^ w0; + r->w[swap_w ^ 1] = rk->w[swap_w ^ 1] ^ w1; + r->w[swap_w ^ 2] = rk->w[swap_w ^ 2] ^ w2; + r->w[swap_w ^ 3] = rk->w[swap_w ^ 3] ^ w3; +} + +void aesenc_SB_SR_MC_AK_gen(AESState *r, const AESState *st, + const AESState *rk) +{ + aesenc_SB_SR_MC_AK_swap(r, st, rk, false); +} + +void aesenc_SB_SR_MC_AK_genrev(AESState *r, const AESState *st, + const AESState *rk) +{ + aesenc_SB_SR_MC_AK_swap(r, st, rk, true); +} + /* * Perform InvMixColumns. */ From patchwork Sun Jul 9 18:28:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700854 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827294wrs; Sun, 9 Jul 2023 11:31:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlHwSsk5dkFQpIXoN5WwS35lkwrn/jJBrSmM9xu/yae07POoSNToS5BtL13xanF+Mz+7DlGs X-Received: by 2002:a05:620a:44c6:b0:765:73e8:da9b with SMTP id y6-20020a05620a44c600b0076573e8da9bmr13936266qkp.78.1688927509048; Sun, 09 Jul 2023 11:31:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927509; cv=none; d=google.com; s=arc-20160816; b=HYORNJH9sQKjOAdab9iOqdzW5dhE1OxzJVu/3IfNicqHjCaknLSOPt7efHUC+BFRj9 +DHDHPlpVq8pNNZ4t8/AERjv5nRodhttIczpKUdzbK84N7TrFL++qgWZdlk4zq5GQGyS 3mFFBYh8NFlJDb6HOGvaXequF+xXVcSQe8ob0H1PWjZM0rm+rkXIPHHx8nnvkBCjrnQr jjtfF3cgpouAo4BeiVr/Xfdeh4feAbnDJtL7JOTl1E4LWfK2qVLQVko0QhXvZuUOd5+5 JcTXMGFugEPSJnulFNda6mSecKfsJvnrmYGEJfbzmny2qdmehIaUQ3M9PTMEtbzF8RQB w+LQ== 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:cc:to :from:dkim-signature; bh=bjel77SnKNWNctLdWi3qeIHBWb+IXzPkj8iWkSio4Cw=; fh=5s19N4v2JlXpEkFgkc3sswK3fL8V2plB1o7R02nrQbs=; b=mMXbDguy8iKf3auRsoc9mMJ4nZ8oR/RLNb8Y42mPbJGHtzmmsmuo4ENA7YTNy825w7 sqCt/PRTY8WAvlZA9lFt/nJN3H4nDffBkX6rcQ2vgHUHlFMq/cUia4OmyfhA9ISmNjtI c0MOgpk9vjJMAJ9lyqLAnllDPsurjdKpZ5ngcp5VvPmrRttpw4YT+xHGH7PqlJCQvMTw hw0bpaNShkvjiiJ/EqTQwRakGNrAoJ/yKJb5wgSxZOJfI5nealT1oDEQesZ0m0BHPIMA /RMahwhMCJDRl/Hc8XEbkmZfyEhEKKQAjb3hj4HWSKsQ3hM2+JLVt9WaPmdxE5Lm/Q5X 6YPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z2AcgigW; 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 n19-20020a05620a295300b00767c5317aeesi1940612qkp.231.2023.07.09.11.31.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:31:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z2AcgigW; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAW-0008L1-UM; Sun, 09 Jul 2023 14:30:00 -0400 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 1qIZAR-0008HN-RY for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:55 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAQ-0000HH-4q for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:55 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fbc244d384so38081755e9.0 for ; Sun, 09 Jul 2023 11:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927393; x=1691519393; 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=bjel77SnKNWNctLdWi3qeIHBWb+IXzPkj8iWkSio4Cw=; b=z2AcgigWyJgFm1tUG1xzDL7CS9a2LyzJzFS4KxiQPEv65MlsRwfQ2ir6OgVdQ22Jp4 MF0X9uPpVKj7l6q6aQmQnTaNROM3TwE8qIO//5qS/XF9/QbMQFyQ3zQqUWWg+713Mtkk F4fl91NFQEOzNTTMqZrxV38+HvNTcx7pbg2/p2FY6tHx5WEZkRJ0WBXUKmOYYZXHu+8Y QfVS/YKIu6uexsMRT96olFD0r2llVM9UBmrexmAmHIjDcjAGxCQhBeWxky/oOxCroI5H lI16wKrg9geknkLD45HmHKWG6UE/Hf2KWJMrLKizLhz+YTexNzFJ3zf+vqpjhmvqFrci JiIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927393; x=1691519393; 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=bjel77SnKNWNctLdWi3qeIHBWb+IXzPkj8iWkSio4Cw=; b=Lky6ue+tnko+tNM8jJzSFDx0ofTsUJHsFf1lgTRyyMwQmO0QlNX2fDHu3WSveh3Iei n8mxZxiMCLdJmDcCKWBZe4tnfb6CSTmHFEXI0UMknxJahE9o6VtUsAdY/BIHF3BWCLlE kL9Cbc3BkzbJgYUJ7e5/smYPXSnJTqcjsqEb9U1/ngBnpFFrSlARTidchTKKqe/mdS4y cZ7uBHLul8/XPq2yx17HamECDPymmr3DvG9sjhcQgh00PH7lmP5pvweMINCarloJ9u6u Zv8Zrb2qV1YTbm+ZmWXkOPIC+PYWxA0oSGmZYRY5q35lM8d1i9qhqzWj9s+3+wH8S1Jw BQrg== X-Gm-Message-State: ABy/qLb0B/KD+N5N0RKJUkUbCs+uZSL390OA9lyVAEfuWR4wD7s1CW01 RYe1MG3LXD+l5BHqIUKScf7Vgpn1DfoPX5a9zsjvhA== X-Received: by 2002:a05:600c:20cb:b0:3fc:f9c:a3e2 with SMTP id y11-20020a05600c20cb00b003fc0f9ca3e2mr1632065wmm.6.1688927392911; Sun, 09 Jul 2023 11:29:52 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.29.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:29:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= Subject: [PULL 10/37] crypto: Add aesdec_ISB_ISR_IMC_AK Date: Sun, 9 Jul 2023 19:28:31 +0100 Message-Id: <20230709182934.309468-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x336.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Add a primitive for InvSubBytes + InvShiftRows + InvMixColumns + AddRoundKey. Acked-by: Daniel P. Berrangé Signed-off-by: Richard Henderson --- host/include/generic/host/crypto/aes-round.h | 3 + include/crypto/aes-round.h | 21 +++++++ crypto/aes.c | 58 ++++++++++++++++++++ 3 files changed, 82 insertions(+) diff --git a/host/include/generic/host/crypto/aes-round.h b/host/include/generic/host/crypto/aes-round.h index 9886e81e50..db8cfe17eb 100644 --- a/host/include/generic/host/crypto/aes-round.h +++ b/host/include/generic/host/crypto/aes-round.h @@ -23,5 +23,8 @@ void aesdec_IMC_accel(AESState *, const AESState *, bool) void aesdec_ISB_ISR_AK_accel(AESState *, const AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); +void aesdec_ISB_ISR_IMC_AK_accel(AESState *, const AESState *, + const AESState *, bool) + QEMU_ERROR("unsupported accel"); #endif /* GENERIC_HOST_CRYPTO_AES_ROUND_H */ diff --git a/include/crypto/aes-round.h b/include/crypto/aes-round.h index 03688c8640..9996f1c219 100644 --- a/include/crypto/aes-round.h +++ b/include/crypto/aes-round.h @@ -119,4 +119,25 @@ static inline void aesdec_ISB_ISR_AK(AESState *r, const AESState *st, } } +/* + * Perform InvSubBytes + InvShiftRows + InvMixColumns + AddRoundKey. + */ + +void aesdec_ISB_ISR_IMC_AK_gen(AESState *ret, const AESState *st, + const AESState *rk); +void aesdec_ISB_ISR_IMC_AK_genrev(AESState *ret, const AESState *st, + const AESState *rk); + +static inline void aesdec_ISB_ISR_IMC_AK(AESState *r, const AESState *st, + const AESState *rk, bool be) +{ + if (HAVE_AES_ACCEL) { + aesdec_ISB_ISR_IMC_AK_accel(r, st, rk, be); + } else if (HOST_BIG_ENDIAN == be) { + aesdec_ISB_ISR_IMC_AK_gen(r, st, rk); + } else { + aesdec_ISB_ISR_IMC_AK_genrev(r, st, rk); + } +} + #endif /* CRYPTO_AES_ROUND_H */ diff --git a/crypto/aes.c b/crypto/aes.c index a193d98d54..c2546ef12e 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -1484,6 +1484,64 @@ void aesdec_ISB_ISR_AK_genrev(AESState *r, const AESState *s, const AESState *k) aesdec_ISB_ISR_AK_swap(r, s, k, true); } +/* + * Perform InvSubBytes + InvShiftRows + InvMixColumns + AddRoundKey. + */ +static inline void +aesdec_ISB_ISR_IMC_AK_swap(AESState *r, const AESState *st, + const AESState *rk, bool swap) +{ + int swap_b = swap * 0xf; + int swap_w = swap * 0x3; + bool be = HOST_BIG_ENDIAN ^ swap; + uint32_t w0, w1, w2, w3; + + w0 = (AES_Td0[st->b[swap_b ^ AES_ISH(0x0)]] ^ + AES_Td1[st->b[swap_b ^ AES_ISH(0x1)]] ^ + AES_Td2[st->b[swap_b ^ AES_ISH(0x2)]] ^ + AES_Td3[st->b[swap_b ^ AES_ISH(0x3)]]); + + w1 = (AES_Td0[st->b[swap_b ^ AES_ISH(0x4)]] ^ + AES_Td1[st->b[swap_b ^ AES_ISH(0x5)]] ^ + AES_Td2[st->b[swap_b ^ AES_ISH(0x6)]] ^ + AES_Td3[st->b[swap_b ^ AES_ISH(0x7)]]); + + w2 = (AES_Td0[st->b[swap_b ^ AES_ISH(0x8)]] ^ + AES_Td1[st->b[swap_b ^ AES_ISH(0x9)]] ^ + AES_Td2[st->b[swap_b ^ AES_ISH(0xA)]] ^ + AES_Td3[st->b[swap_b ^ AES_ISH(0xB)]]); + + w3 = (AES_Td0[st->b[swap_b ^ AES_ISH(0xC)]] ^ + AES_Td1[st->b[swap_b ^ AES_ISH(0xD)]] ^ + AES_Td2[st->b[swap_b ^ AES_ISH(0xE)]] ^ + AES_Td3[st->b[swap_b ^ AES_ISH(0xF)]]); + + /* Note that AES_TdX is encoded for big-endian. */ + if (!be) { + w0 = bswap32(w0); + w1 = bswap32(w1); + w2 = bswap32(w2); + w3 = bswap32(w3); + } + + r->w[swap_w ^ 0] = rk->w[swap_w ^ 0] ^ w0; + r->w[swap_w ^ 1] = rk->w[swap_w ^ 1] ^ w1; + r->w[swap_w ^ 2] = rk->w[swap_w ^ 2] ^ w2; + r->w[swap_w ^ 3] = rk->w[swap_w ^ 3] ^ w3; +} + +void aesdec_ISB_ISR_IMC_AK_gen(AESState *r, const AESState *st, + const AESState *rk) +{ + aesdec_ISB_ISR_IMC_AK_swap(r, st, rk, false); +} + +void aesdec_ISB_ISR_IMC_AK_genrev(AESState *r, const AESState *st, + const AESState *rk) +{ + aesdec_ISB_ISR_IMC_AK_swap(r, st, rk, true); +} + /** * Expand the cipher key into the encryption key schedule. */ From patchwork Sun Jul 9 18:28:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700875 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827969wrs; Sun, 9 Jul 2023 11:34:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlFGBfu8/67ztkExCliQ8CCUI1PJBibpZzLET2tYeZmMqMXESgcMvuWhV2iYAyE/6HKy5kp1 X-Received: by 2002:a05:622a:152:b0:403:9ace:57a7 with SMTP id v18-20020a05622a015200b004039ace57a7mr8935958qtw.7.1688927644588; Sun, 09 Jul 2023 11:34:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927644; cv=none; d=google.com; s=arc-20160816; b=gKy0BpPKlzL9srJbgjwKodv1rBah7sCs6lsn34i1vxzlbkqey0jBkuhThRgAcTNd4f hhMmdMqazHh7EP1XPYtcJel5/qiApc1HJV1BxH2fVsiNmt0R4PepWsUUmuF9aPfZ8fnQ YVy1jnDwAKuFDD3XN9TM1u6iNN2+5EIYwQ7OrCxijqHKYw0mQWvBpu0C0D2yKgDG9w3k cN8Jh+TDan6c0tYJu2cHqzidCwj0iPhlBBUMa0Ucfly+74zhQPUWWI6CYaPOavubsHle 1v5kd3q26UUzs9l5raTuldXf5rLGF63H8Jk9rwB3BoXy+1i7wNVbcfK43K67WSTukT2J 92KA== 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:cc:to :from:dkim-signature; bh=/QBtvBQSI1Tt7HA/Hos/l3dVZOAq+hVRSg1lIqyT39k=; fh=lMWaYJWKNNp5se7C5JIc/IAy1MaLsIKSBhk4MhqnayU=; b=p7lYia6KCmliJ7GKQo+WCNzbH3di6Rd3D38u7X+rqXCFq0+p+G6U8YucC0T4IDQLkY tKo+Kv1r2YsEXk/XAhJJjeHFB6RqC4dkabiDRtGFxzdSv1+VUIwV+Zpd7hMx6eZH7rSR kArfzbiS1XuUCguyKn7Ub6RfI7OQIKlWwsj/iTb6aF7L8lTpvHLEVb8cLPtxlrwl2XHU qHq/guE0EufQ8WjyzXqdbO2sng7I2NdMrUkn3EAiR5jeATKQrGxYAOdAKFurLA3XYHx2 LZyaKBhTV7ynChbchjDfpNxqX6oUHlPVtVXXvIA9dmviFeGOjO1tzseL0hC/IdrOljjm kH5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LPVTtHy8; 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 n16-20020a05622a041000b004039ef1cdd9si2774408qtx.443.2023.07.09.11.34.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:34:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LPVTtHy8; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAV-0008JT-7b; Sun, 09 Jul 2023 14:29:59 -0400 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 1qIZAT-0008Iy-HH for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:57 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAR-0000Hg-TP for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:57 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fbea14706eso37891745e9.2 for ; Sun, 09 Jul 2023 11:29:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927394; x=1691519394; 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=/QBtvBQSI1Tt7HA/Hos/l3dVZOAq+hVRSg1lIqyT39k=; b=LPVTtHy8rS0l+ARnT9UwhpqFth+8dMEaFGITPAGTXV4iU/+GU903B+EplpYbjnpfMb pCNOpXlSVX3CKecuXOheldX1fxwIZl+91nR6enZjgkcpkX+OcrTx4oAPBmrcHJncJZdw k5565BT8poZE1j+4mJC8NpndqouedIAZ63Zo0KZtgMTkp6QzAdgwReCEw1Q57Y0GKuKM Y9HROJMr1godTBObRmKd4T4jwGikCm/i9C+6AUzsUHc+zaps11457Vlu2iJdlTvR/Wip Dqd1s4vsfpvNHxy98TiiPlnS2p+/SDc4PvHv5fG6zEnq30T5JZPzqxZYqsuJUJuHPbGf XJTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927394; x=1691519394; 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=/QBtvBQSI1Tt7HA/Hos/l3dVZOAq+hVRSg1lIqyT39k=; b=LfEkOFwGIP+VwKnc8NrgG6cGfZ8l0a4BXcMYX+3biuZNSZH5gLw2PqS0kto9GYkKUV WIjolqwfbUeoSuW/9wZFBcc6K/r+YnAVYbX2o/OCWuXAM0w30fmNwOf7+zz/gbhTlbm6 P/c7kWa1qQzyJY23mei6w454INgpMEPo3x6e/9tzECYedBd3KNPIoZZtu1KcvpMn0JAl 1dty8ERU+ucJ4t8rZCTTeDNBsoAIhR3ZHdP9DlYVSovwA+Uo/ykZ6w469KP42XpR6mhx qkqzDUnJh3x0ZUMk0KbheRW8WNDlJ3FffbJbpMZKCgCoUShNbovZAsLxbZ3RLbcot3pF jFVQ== X-Gm-Message-State: ABy/qLYMGB+SPPm2gMaHKvt6u/kmrWcC+KIZLrzzmS0ZrnWhce2YSQR3 INaubJwoE597kEjV2GPANmdYu5jM8THRLhf5S/YVzA== X-Received: by 2002:a05:600c:234b:b0:3fc:dd9:91fd with SMTP id 11-20020a05600c234b00b003fc0dd991fdmr1707665wmq.40.1688927394581; Sun, 09 Jul 2023 11:29:54 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:29:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= Subject: [PULL 11/37] crypto: Add aesdec_ISB_ISR_AK_IMC Date: Sun, 9 Jul 2023 19:28:33 +0100 Message-Id: <20230709182934.309468-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x336.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Add a primitive for InvSubBytes + InvShiftRows + AddRoundKey + InvMixColumns. Acked-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- host/include/generic/host/crypto/aes-round.h | 3 +++ include/crypto/aes-round.h | 21 ++++++++++++++++++++ crypto/aes.c | 14 +++++++++++++ 3 files changed, 38 insertions(+) diff --git a/host/include/generic/host/crypto/aes-round.h b/host/include/generic/host/crypto/aes-round.h index db8cfe17eb..1b9720f917 100644 --- a/host/include/generic/host/crypto/aes-round.h +++ b/host/include/generic/host/crypto/aes-round.h @@ -23,6 +23,9 @@ void aesdec_IMC_accel(AESState *, const AESState *, bool) void aesdec_ISB_ISR_AK_accel(AESState *, const AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); +void aesdec_ISB_ISR_AK_IMC_accel(AESState *, const AESState *, + const AESState *, bool) + QEMU_ERROR("unsupported accel"); void aesdec_ISB_ISR_IMC_AK_accel(AESState *, const AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); diff --git a/include/crypto/aes-round.h b/include/crypto/aes-round.h index 9996f1c219..854fb0966a 100644 --- a/include/crypto/aes-round.h +++ b/include/crypto/aes-round.h @@ -119,6 +119,27 @@ static inline void aesdec_ISB_ISR_AK(AESState *r, const AESState *st, } } +/* + * Perform InvSubBytes + InvShiftRows + AddRoundKey + InvMixColumns. + */ + +void aesdec_ISB_ISR_AK_IMC_gen(AESState *ret, const AESState *st, + const AESState *rk); +void aesdec_ISB_ISR_AK_IMC_genrev(AESState *ret, const AESState *st, + const AESState *rk); + +static inline void aesdec_ISB_ISR_AK_IMC(AESState *r, const AESState *st, + const AESState *rk, bool be) +{ + if (HAVE_AES_ACCEL) { + aesdec_ISB_ISR_AK_IMC_accel(r, st, rk, be); + } else if (HOST_BIG_ENDIAN == be) { + aesdec_ISB_ISR_AK_IMC_gen(r, st, rk); + } else { + aesdec_ISB_ISR_AK_IMC_genrev(r, st, rk); + } +} + /* * Perform InvSubBytes + InvShiftRows + InvMixColumns + AddRoundKey. */ diff --git a/crypto/aes.c b/crypto/aes.c index c2546ef12e..c765f11c1e 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -1542,6 +1542,20 @@ void aesdec_ISB_ISR_IMC_AK_genrev(AESState *r, const AESState *st, aesdec_ISB_ISR_IMC_AK_swap(r, st, rk, true); } +void aesdec_ISB_ISR_AK_IMC_gen(AESState *ret, const AESState *st, + const AESState *rk) +{ + aesdec_ISB_ISR_AK_gen(ret, st, rk); + aesdec_IMC_gen(ret, ret); +} + +void aesdec_ISB_ISR_AK_IMC_genrev(AESState *ret, const AESState *st, + const AESState *rk) +{ + aesdec_ISB_ISR_AK_genrev(ret, st, rk); + aesdec_IMC_genrev(ret, ret); +} + /** * Expand the cipher key into the encryption key schedule. */ From patchwork Sun Jul 9 18:28:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700862 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827535wrs; Sun, 9 Jul 2023 11:32:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlFPvUIkRtSFXub3dxU8jUsAfF6Io24ljjbD00smVJxioiimFoyUfMnrLoGN0iOtvGgHgiTU X-Received: by 2002:a0c:f546:0:b0:626:c17:8b55 with SMTP id p6-20020a0cf546000000b006260c178b55mr13145311qvm.25.1688927557259; Sun, 09 Jul 2023 11:32:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927557; cv=none; d=google.com; s=arc-20160816; b=Q8ZdQp1tYSn0BY9UAHoUNTmaZN8D57BmFwrRvNr1ddfg2XzFRj4PQppFC+ml4q3aMX DhE1L8DML/DILbihb6ViWbg1Rv4UK0nAw/DO1AY2RCqVt0RoQokLavheA8d9h8svkdif Sj1g6Do+ZxgV5gUIbMHkyGjeIXl8Y2j2W5LDB3pn7fSYmbCwV6oweaoBGXUS+iCnbl3s pkFqc2S4H+0Y1d8cjcNoHGfFGR9jF97eMvdguMk6SRuIxsHxqrWGGZ0BqVYPdR/A5B8v d2eH0cY8mo4f5TtGwEZBjsC60X2sk463enKS78YsrLTRnfzZWr6+mr0gyssQ69Xu73yq i+bw== 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:cc:to :from:dkim-signature; bh=gQ2Bxu/rilowTJXaihrKCWkhFlHMy8pQmQA827CvuAY=; fh=3IEiF/YPZ00TE94rna3Orj/L+TRFhpuNf7ElRJz3ubE=; b=kTrbf+ZnUvFWHHT8I4auimLCls7nBhaWCWl4AT+yT3/ocOqA2RAUm34BsWHqhuGhmC uw5j/FqVrrAjXYQVWQUqVtzgkbf4F8jNOPXF4n8JZBexoX0cVhMkH8VMuRWu6SLOjTUU 21w3MUDASv6JP+g7xU/ocqJQcj1bUekfKNr6omCYsq30xxyOUbEs3ICP6RBaxpc9wBYQ kRvizjABFz8zoCYdYdmLan40eKYxri8gDm3riIzZfUKbUrg/ZIib3ManAkNlV8q98fOe jwSZ4SxJjuN4xHqWR/N+J50fbHw0gaa53+uaE3UevZWgRPn1O7DEhHMyUXM9E0KMtrUg 36eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G7JVMXGb; 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 x11-20020a0cb20b000000b00635f23eef9bsi4749346qvd.393.2023.07.09.11.32.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:32:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G7JVMXGb; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAZ-0008MY-IN; Sun, 09 Jul 2023 14:30:03 -0400 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 1qIZAV-0008K1-LG for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:59 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAU-0000II-6E for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:59 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fbc12181b6so42003415e9.2 for ; Sun, 09 Jul 2023 11:29:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927397; x=1691519397; 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=gQ2Bxu/rilowTJXaihrKCWkhFlHMy8pQmQA827CvuAY=; b=G7JVMXGbVm27XstsdKY88WV2VaZmw1oClLJbvPs0pIT5I5VXUNVcRCeGkYnSEtJP4y 624IzqfGLv1tZqrqwVjHnSRk0gM5FaivT8bL/V4CIO8bY74jz4geJeqvF9Zf7AFdvWpJ myOnzv26bbZJPIVYLqq79i3JD0Vr9ehuRWDRM7T3xEsUTYlE9Yh/+s4f83BqRkeG9VME ZtP9FsKf/paqyj4lJLn09CpXuUfmBnEwCL+KOwm5HvgI/naMYohxcY8ZwAiLsXa4j7xc Np8Y9JD+AyjbiUqe/BZRljW9mgNQuqUQ6GMZ85abnJi1hKmfy/sxHbNyAjLt2R9Witbt JQNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927397; x=1691519397; 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=gQ2Bxu/rilowTJXaihrKCWkhFlHMy8pQmQA827CvuAY=; b=ehcRJ8BO7lJQ66IjlGMZZE14J+Wf+tpl/+JBci6F4l83xTZe2u/5psgFM6/Gc+bI3V vOWWYIrSrvq3Wau+t43SN/+UkYOOGAiDxCCsjzIEVGw2GsORmc1NV8Z1ftLjEtjR049v yIWwZJW9LUKHPbKPLwy8m4KmFwiduiwcEissacs9+zZy64tpX/3eIB8L+48cT0aQmcRf W8T0Ekymp/i7FJn70OqFdHSn96ylHPIx7+B6lYfTzpXzYx2+iuJiRi9R5UJ0YrpEM73X Qbh3J2tevkvYYDQTcjKOSPuo1TQvxb/sbgqJ7b4QSIZJfQfbsY/sT/49xEs1rw9km5BN PmHQ== X-Gm-Message-State: ABy/qLYKP9f4AQ1+NGYywpJ/aVPUcOqISSKBU+TZNRP1384SVaPMpHIs E9TdGLf3Qk+i9Z5kyzp+tGkIR354K45TdoMfj4fMoA== X-Received: by 2002:a05:600c:2143:b0:3fb:e58c:7758 with SMTP id v3-20020a05600c214300b003fbe58c7758mr9039174wml.3.1688927397007; Sun, 09 Jul 2023 11:29:57 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.29.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:29:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 12/45] linux-user: Use abi_short not short in syscall_defs.h Date: Sun, 9 Jul 2023 19:28:36 +0100 Message-Id: <20230709182934.309468-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x331.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/syscall_defs.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 21ca03b0f4..9dc41828cf 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -702,8 +702,8 @@ typedef struct target_siginfo { struct target_pollfd { abi_int fd; /* file descriptor */ - short events; /* requested events */ - short revents; /* returned events */ + abi_short events; /* requested events */ + abi_short revents; /* returned events */ }; /* virtual terminal ioctls */ @@ -1480,7 +1480,7 @@ struct target_stat { abi_ushort st_dev; abi_ulong st_ino; abi_ushort st_mode; - short st_nlink; + abi_short st_nlink; abi_ushort st_uid; abi_ushort st_gid; abi_ushort st_rdev; From patchwork Sun Jul 9 18:28:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700864 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827656wrs; Sun, 9 Jul 2023 11:33:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlGdE/dGc6uPz0JZBb9GoylmCNjbY03NAXsHkd2oKULozHtnEzXjEFTk1CA89QoYh7R2oTiS X-Received: by 2002:a05:622a:1451:b0:403:2fe0:a437 with SMTP id v17-20020a05622a145100b004032fe0a437mr14291114qtx.3.1688927583231; Sun, 09 Jul 2023 11:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927583; cv=none; d=google.com; s=arc-20160816; b=wUnwx1E9BTn4iUzcAfWogWCZc04K0qBe32Tx+6ldtR85VzScvS201+QpyMOJYjTUvD XnksJBzfTS0II4/3zyugfeMPlVb5/i2bd+EUtE4cUtHhUA6AypkHo46NsekU0IJcZR10 Nn7xApRtIQ5kAbLMC7rQcZIFYlUkmZM2YQ6ECEVBkacW+zzn/5s9HsUwHrtXeUok7Urq xqfw+e4PCuiU0TcFtWm3lmhwKJYJNQUiHDiXo3buc4NX//yHULR9QVQAByFaLOVg1QsS SXS0DSvlrmc6JZZzw/1Bco9qFco/fdFsSpHVKjEUhG7zbHa10S8Rc4RrXINvU+wHxZ17 54Aw== 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:cc:to :from:dkim-signature; bh=NM1xXL81EtFD9ExbvPk3EQKQbkl//TA55SFLIHfjSWw=; fh=3IEiF/YPZ00TE94rna3Orj/L+TRFhpuNf7ElRJz3ubE=; b=OQ5w8pk46oRmNHW94RfkontDUCoymirrRDRoSZbjTTc1k1o6KquOatCdLO6oPAiGwf Fp0nUT4evZw8IKt9E1/MFlJy6PKW9Q7ynVXiDITuQxDjWbfUfATH118sSaFYtz3ccYr0 jCsp4s5D87syhNVipxX97R07XiiN7HlvVEnIJ1aaFMnEzXQGDSamuNfDPVaVyHXX2/Zb 0DaBS/GxPEhyH0A4Y4DrEdKdMlY6w07gWzo7+svDhnV2UmhgdH/wwQ8oq0Gzq8gQUBOK 5ejkRBLNanBDf15ZzqBwZjnxPc+rI4biGF5chKq6UagI7xINeiAOjK1fJGwinyy4RVzv byaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XSHy+Oha; 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 y5-20020a0cc545000000b0062fe5397100si4830827qvi.144.2023.07.09.11.33.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:33:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XSHy+Oha; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAc-0008OY-5l; Sun, 09 Jul 2023 14:30:06 -0400 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 1qIZAX-0008LD-EP for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:01 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAV-0000Ik-Tj for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:01 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fc03aa6e04so16329525e9.2 for ; Sun, 09 Jul 2023 11:29:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927398; x=1691519398; 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=NM1xXL81EtFD9ExbvPk3EQKQbkl//TA55SFLIHfjSWw=; b=XSHy+Ohal8jIDY3VO1YwT5GP9nQOkhLf07/YqI14GALszfjELoi/tHKdegFdwRzctb rgylzwE+w35s7HjyLt1+zGbEOqRjDZayUBeawtcKJAtjVORY7KQ1MD5aeA4LkXuz6iwy Bf2+WG7dc44pBVxZqwU/u3TLbyAHhQi7FoQTaCiYxpk7fPB/ZAOD55y/COlI+4lpDMxp sTJHHi5CZigeIMNPEGdY3h4H30xXy0b0du2kWpJFYuPJZa33BnHOXN3Pbvln6enFpnac rJTkv47zWvV93ZLUhdbeYkIpn5FwvICvA4v3CwuYMzyhRYyhZPjhSxhL29cPVE/VHL03 7Rmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927398; x=1691519398; 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=NM1xXL81EtFD9ExbvPk3EQKQbkl//TA55SFLIHfjSWw=; b=D0roCjD41P4/7UggHYKY/eT7/lGLQpXCZrkwZpudkNqRfWu7qwWhWrrs5543D8E4Uu iWTBxf3PlSwntGuCoad4aatgwIeQRCIFxMTWREUvfvZQOxOd+UTgpd3q85hHIx4VLSR/ aLLeSTdAmmz+pPbvILizEhbTaOwNO0qK1+Tp1VMCsH20cVvIKOVoj/gRbZKc7xl7zQmW XGLWnxD8TNnfN2cer/SQzAczXWTGv0jdpmZ0OxZumZm0uXWaxnLepMWbvIIBzrmlDxa1 DzCzGWyIpqKoSOW8JOUxhD3LHgBgNe1pDGEo4i8nWHa9v8fStUNFCffx0p/w9bezvLRv 5WSw== X-Gm-Message-State: ABy/qLZTnSo1m4biJ67EWJn0tvTAyaDL2Woji6Ga0kn+guvQQFPce1S0 w206t2enUgjyNCAGw9aI7vuzaoQ70DDCVpBblTv6eA== X-Received: by 2002:a05:600c:3786:b0:3fb:b890:128b with SMTP id o6-20020a05600c378600b003fbb890128bmr8767337wmr.27.1688927398570; Sun, 09 Jul 2023 11:29:58 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:29:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 13/45] linux-user: Use abi_uint not unsigned in syscall_defs.h Date: Sun, 9 Jul 2023 19:28:38 +0100 Message-Id: <20230709182934.309468-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x336.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/syscall_defs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 9dc41828cf..c8ffb4f785 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1776,14 +1776,14 @@ struct target_stat { #define TARGET_STAT_HAVE_NSEC struct target_stat { - unsigned st_dev; + abi_uint st_dev; abi_long st_pad1[3]; /* Reserved for network id */ abi_ulong st_ino; abi_uint st_mode; abi_uint st_nlink; abi_int st_uid; abi_int st_gid; - unsigned st_rdev; + abi_uint st_rdev; abi_long st_pad2[2]; abi_long st_size; abi_long st_pad3; From patchwork Sun Jul 9 18:28:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700858 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827407wrs; Sun, 9 Jul 2023 11:32:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlEDfuV9luTSx//PXRnMW/kA61N+DXZ716PEVaHZJsomSKaMRlnYkajEkLQ3V3MlmHEXCMN5 X-Received: by 2002:a05:620a:4445:b0:765:7248:e7fa with SMTP id w5-20020a05620a444500b007657248e7famr14048779qkp.71.1688927529506; Sun, 09 Jul 2023 11:32:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927529; cv=none; d=google.com; s=arc-20160816; b=qPSpV0KLy6rMRLBkz3ErUO8oiZ6WQxbwsRSuVHqz1cTKEGb7SprhAJ8zrDhHKSfrcO EguBhNJv7esfjaQlANDExgew+9fdRVlstHFa6lB6PfTw47ARMEQ6W7PPpZDrwlFROgg3 7pkHWQgGcCmjfkDJQ3aM/0Si65YJQ/pMu7BiPvAZ16smG27siWgetvlIq4PswML169GA 2hYiL1ub1YRTdOEtsJ3PA1rOsZx/sC+A9cAnH2e/0t6LuyusBPSAIl97DgVt0NWROh10 4Cv9bCyAZpNhHtnkwmODUMSUAzoalbGcNHU7cThNlKN3pxReCkNSA7WWRuhCwqBQ7Uy8 n3nA== 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:cc:to :from:dkim-signature; bh=TsEvG+VWvCxR8wzqDIyWaXPHqC8uQbp4ZRAeyYSrQhw=; fh=4nfr0hkxlMpWE4oToQ1q4rzQVecv6te3cGVRc3YFjiI=; b=mUkltVzZ7qHf9752dvp9FzC36XoP72hrdx2lKgfHYSWNEMX5KJ1jjjP1+/bg3MTANX qyeiiC9zR2iRN856cr0fm9UmVbU4PlaKUwlMjRufuD36aPJhVfmUEdlh7EbMBO9CeaNn +5WseTDIevvrDDKc0gSmj/vt9LyCmmmtqF0ZNt4Iai+wINUXxTmDKFh5L/ZXrS6f4OdX HJJsCLZ63rNDjfYXI/bMl0BHvmQ/ax/ArG8FNkBN6c6xuEiUr31+6JxernCJHN1JjWYJ pTm130XZ4eb+fKZrTaS3QZrOL91+DNknZGnEb4USP8Npl95ONc//1BNFvn0fzUl628Mc Wi7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RqvWPhZs; 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 pi1-20020a05620a378100b00765ad978f97si4787609qkn.517.2023.07.09.11.32.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:32:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RqvWPhZs; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAf-0008Qp-KL; Sun, 09 Jul 2023 14:30:09 -0400 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 1qIZAc-0008Ol-1W for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:06 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAX-0000JC-AU for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:05 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fbc5d5746cso43742245e9.2 for ; Sun, 09 Jul 2023 11:30:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927400; x=1691519400; 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=TsEvG+VWvCxR8wzqDIyWaXPHqC8uQbp4ZRAeyYSrQhw=; b=RqvWPhZswLWUrpEQGmY7oJWN9eiH5da86YPgh1OZXD4H6go/r+/GGnofRVrrE0jHlz tYq42UkMFZ9qWTybgSr2PO+8aySdpQNBwaHQZNlKkC/zWJtXvHai85xCVXuqKseh18yp T8VYVmF4GbkFruL4+5qcna8QsiUeJqfV72JkocjSbjnC2nUJDx+gPNWY2rqS31l6vFqP WvsoQ3C8Qciwlp1DvNPwTNn+z1Ekn1yBlVvpf6mJ+hQjUFVHAX//K3AivhOW1D1AOMBV vdHovHt0Jvu8uqAlgNRO4mQsX8FpWXupUmakU3/hPaDf/qbLndWIUmSQdixYhLzuhNP3 RiUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927400; x=1691519400; 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=TsEvG+VWvCxR8wzqDIyWaXPHqC8uQbp4ZRAeyYSrQhw=; b=D/XdSSdOoWsHepmKn/gI5FiYswavKlLdf7sTW1Ze2k6MI8dQkKxX6NoZxKENL3RmSS jMVnNug7e6IhrAmMkFhefOeBMezihnb0N5vm3YrzP5pFE8oKiJ1yB+YRrXJJnMKTXMkq Ib0OhAHca3zxkPlPnJyQ1qCCg0Yy8vvwoywngP9G+l8DxNfXSYndSkuHoH9yZkIn75Hb cnDpkr4q0EIxHqWAsTiWSjPthNQm9ixnJlefhRn3slaZy/UYdNNXlOvHn9O+yBq1FTly M3JRGRzDgjuGd8qugxlCmUtW8dynbjag1KFLiJadkD2YOKpkoztE+cMEJp8Mtv6Ey+Ik 6EBA== X-Gm-Message-State: ABy/qLYr166DLkPOEIwnOayuFVRXLQBfaDCL7rtXIwIPpAnviqp1pmHJ PlpWWDAYUwB+EBghtEJDrrcDZ/ZVJ77j2lrKDeCEPg== X-Received: by 2002:a05:600c:29a:b0:3f9:b8df:26ae with SMTP id 26-20020a05600c029a00b003f9b8df26aemr9850639wmk.34.1688927400052; Sun, 09 Jul 2023 11:30:00 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:29:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH 14/45] include/exec/user: Set ABI_LLONG_ALIGNMENT to 4 for microblaze Date: Sun, 9 Jul 2023 19:28:40 +0100 Message-Id: <20230709182934.309468-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32c.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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Based on gcc's microblaze.h setting BIGGEST_ALIGNMENT to 32 bits. Signed-off-by: Richard Henderson --- include/exec/user/abitypes.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/exec/user/abitypes.h b/include/exec/user/abitypes.h index 743b8bb9ea..beba0a48c7 100644 --- a/include/exec/user/abitypes.h +++ b/include/exec/user/abitypes.h @@ -15,7 +15,9 @@ #define ABI_LLONG_ALIGNMENT 2 #endif -#if (defined(TARGET_I386) && !defined(TARGET_X86_64)) || defined(TARGET_SH4) +#if (defined(TARGET_I386) && !defined(TARGET_X86_64)) \ + || defined(TARGET_SH4) \ + || defined(TARGET_MICROBLAZE) #define ABI_LLONG_ALIGNMENT 4 #endif From patchwork Sun Jul 9 18:28:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700863 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827597wrs; Sun, 9 Jul 2023 11:32:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlERfOi4hE9zdf9uHYMmidGdM4nnscfebjK9km5ukcljL6EPWxGakV7+Bgj83tLqZhMCsSrw X-Received: by 2002:ac8:5b41:0:b0:401:fa32:3594 with SMTP id n1-20020ac85b41000000b00401fa323594mr13099290qtw.27.1688927569434; Sun, 09 Jul 2023 11:32:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927569; cv=none; d=google.com; s=arc-20160816; b=jdrH3D54V3+3/uqnYaS9b2etgGYRzxrAr1p750BHaJlE8PCgvHw5D4gzwEqLu1Q37l 0juUtS45VUb7o8xb0wgbjJm2lyGC0pslkjhpzx4mHY03WM1gWqFPlzTPKRAptQW0yNuf JVFQxa7v6zw5PA/XFMpMOnGT1TCdH1vFoVBk/aN9VGL2VENfoBoDywKec2pVopzLLerb XXuYg9cSo7xw1glG4bt9+/JIbJDaGC1Xl5i1ydKsGhpWaOXleJnuxzdBplkOn3s95XXk t1Do7i7C7zFpPDmBJlyc46Iabf90/9lv30+Vb0JUrH8bZbZLycuh5XMZnLN+PHEfosZU Tubg== 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:cc:to :from:dkim-signature; bh=CXOtR+skbBy3g0n+KA4k0jDRJwr6870/fEeTqXEf6Vk=; fh=vt5PnLhDoDj0CK6sQmjgOuq7ZR8IvVqHabl0gLsltKk=; b=FTsD/Q4XepJJca9P8RXfq295hxT1EKbH+6XrePEjLOvzJsBGjMJzbbKr0dMpYHuO+2 NaCoTEI8tlLymlBddRLxrSglN6hwVdt+A3+uscGw5CghLWqH0VfhBR+uRs2Tck+sJUCR jAQkg4+OzoUuZPWxalR77129zU5B/+heYf06TQO29kTJpR5+SlqQVMmJtuiNzMgkpinj LYyEUDlwL2InXW1GSe5iUt9IyfOBH5olq1K0TgJNxxM4S4FR0Uq4L3z4S05H4v3tRXyb 9nTaJOH06dW2TVxkktWZiNJZXH4zW8wfcLAvJiPq3psJUlBfju3FKaZWmvkP+GhwHL5n x75A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="kq5nM/8V"; 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 k5-20020ac85fc5000000b00403783aa68asi4696795qta.583.2023.07.09.11.32.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:32:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="kq5nM/8V"; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAh-0008R3-Ew; Sun, 09 Jul 2023 14:30:11 -0400 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 1qIZAb-0008Nf-09 for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:05 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAY-0000OI-VE for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:04 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3fb4146e8ceso39577995e9.0 for ; Sun, 09 Jul 2023 11:30:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927401; x=1691519401; 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=CXOtR+skbBy3g0n+KA4k0jDRJwr6870/fEeTqXEf6Vk=; b=kq5nM/8V1fbL/HGT4WA84cEPDr8adVJ1cSAFLUUXLQQzgRdNaJ7Z4FcNj8a5es0RR/ CutRueH5nIkzWor5xybOo0ZWSvpyQGzn61i6SN+/agdHhwX8adravJEZzMpuKBUZC1Mf 5mAdolmpG0xlqVkmgBh+tCdk0KiFahH5JaPdKlMyqo8fkuOQmaWaP2z3ELZmPCaBMB4u 9/l4AtnAV7dXyPL7aR59Bky6SZg78f5po88UzJxlC3tcfS6MYdlNSDvit6vS07qf5HbD jL8/QenUikd//P6YLJyxFr2lCmK/W1R8carYQ8vXE8aTCPk2qPo6bXhYFEHselJh1YN+ 4tuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927401; x=1691519401; 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=CXOtR+skbBy3g0n+KA4k0jDRJwr6870/fEeTqXEf6Vk=; b=L4Vbcw0Xywb9wsvXO0dTN1vbLl3twBxsIIQIcMoO3ssVQNnlcovwPie/zv8i7FllVJ nbjhlWFwjkZ2vSDGGC8AopfD4KPFpHvg2lyRS2Y6xh77CNE/eN4GgkeZRPFKj+RQEbyS DLhmOKlKbW4wsMHSvaC1cIJiaZsm8dRcV+8eq6Xa4comlMAzYNLb/QpRMuWtpJO+tWaH 6IDc8+v1rW/zLFEkyh8/EB01cDzE3278ElnQGA7fkPeXBSRyzScUX5mJCKLuKUkIS0QL eLnZj50nVxI4WJcvk+kgz54wqniKgtCyNJ/eU0YzK6Mg3V6i1DbS/8u8dDPHAg5d43v0 kHmQ== X-Gm-Message-State: ABy/qLbYY00P8Gpwa6hcIZvV0AuIrIO5R2lkYoLoSdo9KYBZd+d7Bbcs +jhtJJqifdgxUVgCaW52RvYtVkNZMHE4ivZpL+ismA== X-Received: by 2002:a7b:ce8a:0:b0:3fb:be07:5343 with SMTP id q10-20020a7bce8a000000b003fbbe075343mr8867367wmj.27.1688927401676; Sun, 09 Jul 2023 11:30:01 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.30.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:30:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Daniel Henrique Barboza Subject: [PULL 15/37] target/ppc: Use aesenc_SB_SR_AK Date: Sun, 9 Jul 2023 19:28:42 +0100 Message-Id: <20230709182934.309468-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32a.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This implements the VCIPHERLAST instruction. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- target/ppc/int_helper.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index d97a7f1f28..34257e9d76 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -25,6 +25,7 @@ #include "qemu/log.h" #include "exec/helper-proto.h" #include "crypto/aes.h" +#include "crypto/aes-round.h" #include "fpu/softfloat.h" #include "qapi/error.h" #include "qemu/guest-random.h" @@ -2947,13 +2948,7 @@ void helper_vcipher(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) void helper_vcipherlast(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) { - ppc_avr_t result; - int i; - - VECTOR_FOR_INORDER_I(i, u8) { - result.VsrB(i) = b->VsrB(i) ^ (AES_sbox[a->VsrB(AES_shifts[i])]); - } - *r = result; + aesenc_SB_SR_AK((AESState *)r, (AESState *)a, (AESState *)b, true); } void helper_vncipher(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) From patchwork Sun Jul 9 18:28:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700867 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827816wrs; Sun, 9 Jul 2023 11:33:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlF6vNT9AJDBO1XPVCd2W5dH29nSa5K9UfKJo/ZLRr3ySweQnLZTsBIISAKvVbbMoXNSDFdg X-Received: by 2002:a05:622a:1213:b0:403:3a32:3f47 with SMTP id y19-20020a05622a121300b004033a323f47mr13830443qtx.15.1688927617248; Sun, 09 Jul 2023 11:33:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927617; cv=none; d=google.com; s=arc-20160816; b=pJ3Mzwu485VCSgdpTGnLzq6bstQI2tutnssbzS14Fv5TL4RtC52EbWTewIFbh2juoq Do/Jhb5G1c/FFIFU898hUM0f+bpYG7hrxj+qOhXD9jTxXNCoaWZAviZyLyP4ofpRiTxu Mpvg7NU8ZxgETcBttJaPvV0YPL5FUPmgI7mBO1ntIXJ3qhG4HD7AP8yc170O4Rceb38a HOXj6NUeTGLUXQ4ZIE72ia72I8nnP+JevHRvMmL7ZwYWtIGAKGvmsSpQ1HDSI44oEXEY 0WPfBk41lb7Vqe6MzFMsh1P1LRNi2VRU1CW/wU9GUsaKevNSzWs5Bb280i8az4Fhn9Qp PcLA== 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:cc:to :from:dkim-signature; bh=9eRhNGGsvyXPq3UhYSn/b3L2GTywYRMcqzsZGePD5qs=; fh=vt5PnLhDoDj0CK6sQmjgOuq7ZR8IvVqHabl0gLsltKk=; b=1FmgdduDpTYJCLFEYZO2uBW51juz97bfl/HzsZOPr8EhI+xap2qKa9rkDDljDBpYO8 tWS/dLJjTJGfG9ZuKZMstMNekvorplyH77n5cXRwzFw8nb8+RftqGFBaU5xpmuCbG5rU k6W1vjMaxP03D+b5AlzADwJea3PjDfrJPr+0lUTg96ENGd+JJejSOYkpY0ouI7Mj5W+6 zbabN5Mac+WUDguN6Z9eLrC7Q2FuSCB3WI7frHbt7WG0Mey9mCgJ+pJ5BwIRKr6vLHnE fNN+fUg0mMXxcKnCOxzvSr90eZ0rn0brpv7hcdbvt1O1DnDkk4W7swDJ2dJl7Ec0eS1B rwJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wWoSBeyQ; 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 t20-20020a05622a01d400b004034b8900b7si4870158qtw.713.2023.07.09.11.33.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:33:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wWoSBeyQ; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAk-0008TB-BX; Sun, 09 Jul 2023 14:30:14 -0400 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 1qIZAc-0008Pj-NY for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:06 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAb-0000er-5Y for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:06 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fbc244d307so43911515e9.1 for ; Sun, 09 Jul 2023 11:30:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927403; x=1691519403; 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=9eRhNGGsvyXPq3UhYSn/b3L2GTywYRMcqzsZGePD5qs=; b=wWoSBeyQtz2Kvn2ZT1cR7JzFjct6vWELQuyHQYdETo71nV7I9Q7Ujrdef8tMgx9kKw cqdTl5aSGNVgFw8rUL/MRMtUiioaZgviT8cB5wBWA5WCNDycHB7hSM7g3glqjSI0tXbn rHrzlA0J/rPqdx3zCDVP33rNZceJ3ncha40oE9zyP/e6+v7MjzkJ5o/WBZmOkaLVqS++ JTeMpaRHZQexwxfqXVvLxu6VBccaQpV6roaJshN34HZ2TWyBIuZLsXy2p7UfB+kmabq5 YSZ86iTYM7pnZRWn3SP7Ac3R8W/euuCUpHEHZJ9H0dDbm1kiKv+AAcuNpd1tW2MskH2Q qd8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927403; x=1691519403; 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=9eRhNGGsvyXPq3UhYSn/b3L2GTywYRMcqzsZGePD5qs=; b=b3dCBTTJJewT4IxOPqVpH+J8PeN9HMMGft9sriPJy/y8jFALBeybvIwkAP2Z9f4QTY LlaBUp3LPTr4whPzaAjSCNfqUUI95j4Lb3qMT/P+dh6FVFxyYGy2UkWH6DJzWSS30Thr RdCaIoV/WXJ0Yg0SukAucpkIBMD2RYm05Oi0TJBu+lIeQlPF9SXp6fWrzT/MPDaVJrbN 7vQ2edhhtrMw3kSbSlrDjrTOy4I8YYDrx3X1ez1Jyn0SGHpMW0g60pAX2IsXlm3r0IF+ HIjiL+SD74PnqST97/1f+MrhH0y/VIH5yuvl4DZoEoZF9ggd6ENvPaP9Is2VJ2eikIFq Uh2g== X-Gm-Message-State: ABy/qLalTTkndn9sqPxj5CGyEjbF50r0n8FNjFus6p27cCoxbHZ6HK2I KsfB08z9bSTEGyZLcUTmBaEJkHCPQ+4jIDF2XMhRXA== X-Received: by 2002:a7b:cc9a:0:b0:3fb:40ff:1cba with SMTP id p26-20020a7bcc9a000000b003fb40ff1cbamr10936308wma.6.1688927403790; Sun, 09 Jul 2023 11:30:03 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:30:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Daniel Henrique Barboza Subject: [PULL 16/37] target/ppc: Use aesdec_ISB_ISR_AK Date: Sun, 9 Jul 2023 19:28:44 +0100 Message-Id: <20230709182934.309468-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32f.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This implements the VNCIPHERLAST instruction. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- target/ppc/int_helper.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index 34257e9d76..15f07fca2b 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -2973,13 +2973,7 @@ void helper_vncipher(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) void helper_vncipherlast(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) { - ppc_avr_t result; - int i; - - VECTOR_FOR_INORDER_I(i, u8) { - result.VsrB(i) = b->VsrB(i) ^ (AES_isbox[a->VsrB(AES_ishifts[i])]); - } - *r = result; + aesdec_ISB_ISR_AK((AESState *)r, (AESState *)a, (AESState *)b, true); } void helper_vshasigmaw(ppc_avr_t *r, ppc_avr_t *a, uint32_t st_six) From patchwork Sun Jul 9 18:28:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700865 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827724wrs; Sun, 9 Jul 2023 11:33:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlGTXxht/Xx+C3dREVk4kWvn246Obptcx6PPsjfkS6czxy87vZ/RVUl+8m0UbJOMQJ7xmuu2 X-Received: by 2002:a0c:f5ca:0:b0:630:14e0:982e with SMTP id q10-20020a0cf5ca000000b0063014e0982emr13311573qvm.22.1688927596360; Sun, 09 Jul 2023 11:33:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927596; cv=none; d=google.com; s=arc-20160816; b=gx+coxGrqH0Yg7UA5cAjirA82Efkr0BafljJ1IOjUAGtZcj3JIQeyaIvSlNVjO2GuL Nyiqp9pcG3q0iU2jqrQMtEbGVSPPJn2VlhWkrDeFDvCEH2UtraNaIZwrqqAejjj8Uhdk 2Xo1aIkfGiuf43YZWUNZRu5GmF9ibgsHHdWhDo+KYAun5v6vH7RmHiaNBtJRyUBKMpNx QsIUQOFzy9e1ej1jiGGy71lPKi5Z/bEPQOCaN2Sjdi2GIR28G9hXaDs/cLQ4UevQSsjh nxBU1iHLcFZfwcbGq+o1LgDKQTWiuXIsHtnuAgTIpK+pvFcRsQkLm3TO0fudxGZZlJG5 d7Xw== 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:cc:to :from:dkim-signature; bh=7wgRkP+eTRpLGmcULxLxPDzJcG5/xUKxzegn/jzfjvQ=; fh=VcMCUcffQ67RgCkJyoptnrkmR5uIxeYQ3oU0Wl+G7zE=; b=aShBfEGFGD/kh+M0Cl2rplGk23a6ajZpD7EI4QkT7/Sckote/aYRRr4uoHLzLEv5nq kSDzSy8lVUUPqf/m0zwAxeZmvRxCTnTVqbFHNlZSa10qVl9xkc2Ux8UpzsWOP44ViCxa J4wiF/ZDYhUKXn10uRhgq1vkgpBwLmFZIFYkKwj6PfUQpr2vDkbbNtX+TkJTpfHp0dyO vHKEt+/ZFTIlZDTpXDHoOsmrpiny9GeKxtk5cOFwZjToaLUGANda3buuHkIKoElkk/lB 7B27IFeMaXMaRJcIsP5wvHZ3kRBaVp7Pjhl5Ntd6oxkXFhIuXO4Qdk9RzszxJ5KhazTG 04IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BYpwpxBm; 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 oq31-20020a05620a611f00b007679de91666si4926598qkn.679.2023.07.09.11.33.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:33:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BYpwpxBm; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAk-0008TJ-Js; Sun, 09 Jul 2023 14:30:14 -0400 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 1qIZAd-0008QE-Iy for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:07 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAb-0000jI-RT for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:07 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fbf1b82d9cso39246225e9.2 for ; Sun, 09 Jul 2023 11:30:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927404; x=1691519404; 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=7wgRkP+eTRpLGmcULxLxPDzJcG5/xUKxzegn/jzfjvQ=; b=BYpwpxBmTs82k5/T6au5xZFWJuFUH7T3jVewYQgZ86kR3kuz/bFDLQAMt5yUC/f+Hv S6gnfqiqa/ODqL36pAqv41mNxCXMbDJzfBkBg2KATee+v4N482nEJimST0Bgu/tbMMmq 5jUcgbataQfFN+2wa1aF6D/4OonEQI3EFGevVHdgiHppwnUQU2Axu+YqX3OHZ5fJNpzY octySGu36QuphRsoOhL1Z/2XrRlxzhUS8wCdIq/dr27D0lQS1itxjtlwoX0DFgXIaVSf Vfec7J62kPodI9rTDiwFQFY135v7U9NrNU2ORDj6fv1G3grrGfyV8e6vXnO8EXANuJsZ XJyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927404; x=1691519404; 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=7wgRkP+eTRpLGmcULxLxPDzJcG5/xUKxzegn/jzfjvQ=; b=NWGB5GgizkzEyum3UFQlj/4pBCPfUNMUKrnIFQGZCQZG3WmTidDJPJAlaUgm0uZNfy XMOV7JbVU+6FOz2Zw3h4iPibWqCINcxnBKo9KL5Ld78ATlBrHVRecEgp7Y9tK5a3JOD5 r5Kdlt7efI+0y80e6gi3XVgaFSwn75ERxsmmQqjfs6qEKQwwZkVhW8ee0ib9rfNIfPhM 1PYdY+vQv+RmbhMHsJulRRQxLug8uAqiP14i94+BoHoqkCzlbKP7h9T/quXCM/Dh3ssw nYMnUk7/e3G8qT11kRiEF1TDAbhJkOgrwojpgMn93zSEi+dRNGsx2FlHzhY0uYNMsUwv U0tA== X-Gm-Message-State: ABy/qLaR+4tjkz/nN+b3exrE1Po4Y4Fdq9Zu5n8G8+y/AePwj9gsNUBn a5nIVF+KIHoGubnxls1QcOLcuIhJAU6IfeZU6d75iA== X-Received: by 2002:a7b:cc86:0:b0:3f9:c8b2:dfbd with SMTP id p6-20020a7bcc86000000b003f9c8b2dfbdmr7986664wma.19.1688927404614; Sun, 09 Jul 2023 11:30:04 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:30:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Anton Johansson Subject: [PATCH 17/45] linux-user: Fix do_shmat type errors Date: Sun, 9 Jul 2023 19:28:45 +0100 Message-Id: <20230709182934.309468-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x329.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The guest address, raddr, should be unsigned, aka abi_ulong. The host addresses should be cast via *intptr_t not long. Drop the inline and fix two other whitespace issues. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Anton Johansson Message-Id: <20230626140250.69572-1-richard.henderson@linaro.org> --- linux-user/syscall.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 90777c5833..8b12774fba 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4529,14 +4529,14 @@ static inline abi_ulong target_shmlba(CPUArchState *cpu_env) } #endif -static inline abi_ulong do_shmat(CPUArchState *cpu_env, - int shmid, abi_ulong shmaddr, int shmflg) +static abi_ulong do_shmat(CPUArchState *cpu_env, int shmid, + abi_ulong shmaddr, int shmflg) { CPUState *cpu = env_cpu(cpu_env); - abi_long raddr; + abi_ulong raddr; void *host_raddr; struct shmid_ds shm_info; - int i,ret; + int i, ret; abi_ulong shmlba; /* shmat pointers are always untagged */ @@ -4592,9 +4592,9 @@ static inline abi_ulong do_shmat(CPUArchState *cpu_env, if (host_raddr == (void *)-1) { mmap_unlock(); - return get_errno((long)host_raddr); + return get_errno((intptr_t)host_raddr); } - raddr=h2g((unsigned long)host_raddr); + raddr = h2g((uintptr_t)host_raddr); page_set_flags(raddr, raddr + shm_info.shm_segsz - 1, PAGE_VALID | PAGE_RESET | PAGE_READ | @@ -4611,7 +4611,6 @@ static inline abi_ulong do_shmat(CPUArchState *cpu_env, mmap_unlock(); return raddr; - } static inline abi_long do_shmdt(abi_ulong shmaddr) From patchwork Sun Jul 9 18:28:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700855 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827326wrs; Sun, 9 Jul 2023 11:31:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlHo7xW3Wm9cjaPz1Fnuw2oUNieJ06tSIQyi+RjBYenlIpRYw5nEwmHba22Qt8O2t9+3qWhV X-Received: by 2002:a05:620a:254b:b0:767:a1ac:3c74 with SMTP id s11-20020a05620a254b00b00767a1ac3c74mr11454668qko.26.1688927514514; Sun, 09 Jul 2023 11:31:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927514; cv=none; d=google.com; s=arc-20160816; b=RsG/apMBXIhP0UdzA/hR3KeD2UwOFpS/ta0t95d/1D8yody2S/8Bmq+3viIyxIpgNw u9Z6Y9yU+laqK3//f+jhD9ITnKCTNUGDJDdbqorAiwiw/QI+eTyKG4IM9/M67osOJLrp 9yavpmJHJ/SVu4tF2RvknNFN86UnXhRSblUoFdqI19CbjLPF31xfJVgPHg/4bTvLamti 2GYaT9TRuvGqsFcI/JeYruobg4f9hYcnucHz8MpdbLYE1sDMKZFVVcdbbTAyUmbRyHgK pH/C7Q4nZy1gLKanKxAaYsGDu8D5qLlCDGdkzEmVxOrDUzNESFhEg5tU4uN4581Ze2C6 JF3A== 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:cc:to :from:dkim-signature; bh=NQsBpcgKVgYp7fXYDQVN06TvKGcdOIek7QQgIG6AozQ=; fh=vt5PnLhDoDj0CK6sQmjgOuq7ZR8IvVqHabl0gLsltKk=; b=V3Unq6iLgY8jBcweX5Jd/AbEjgNHi0gbgY3iV8AKocuFKgmG1jQT3XQ8E8r+aAVcF6 uddn0so16BHTD1aaHBCNjqLgdl0GILvFx5lwigyvJUpfQj8Ho0lxSGHHZpI4GAuqbGsp A5GPe5nj3sxaL3o1G4UludNyIGCROuJiGjPf4LrFg48dJI2qJ06DG+EngAjVTH9ElyE/ FblDjlrdKzXvu61S4zz9ASATuarf4lcfKK/ywfrfJZsgFszlPVPM8nKP7K2yuQoAaVvS 1e0iU7k2EKxA9497z6MHLhB04vI5j4WDvGHhhLt/KvWp1gCWxBaBzh0igmit0gYbVWrW nLgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LYvQNQqK; 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 e19-20020a0cf353000000b00620dab812d0si4874901qvm.292.2023.07.09.11.31.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:31:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LYvQNQqK; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAo-0008UG-7g; Sun, 09 Jul 2023 14:30:18 -0400 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 1qIZAg-0008Qz-Nc for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:11 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAe-0000zv-OC for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:10 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-31438512cafso4023494f8f.2 for ; Sun, 09 Jul 2023 11:30:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927407; x=1691519407; 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=NQsBpcgKVgYp7fXYDQVN06TvKGcdOIek7QQgIG6AozQ=; b=LYvQNQqKa9oQdsqMxVZReVZejXOyQ+yzk60giB6vYUv9EUi8RFB9XrlUqYedBzHdNu NcB5LW4XA0oDPVvHVZ3JlaMuH9OiPmu4M2G6ray37th2tZr+CSklbkhabeWCS8LIgBj0 /DIQTC8OsE+fuL1bHXa6l3F8eBU3XfIXAUZEbbNjBgbT6PL4CgtUzU9sOdP890svlWNu G3OQmbBzT2JkQG2x37ctLSgFR6gmb1bOR1QlqzeEFZy0jv5Co7La5Zbp9qpe+iBdCYxr Vjl7h4SmUOrDOD2Hm06RT9fmiRfxHikn978KZ6sfFymrsHFpC/2CSVKTzNC4gdqp0M6e z5mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927407; x=1691519407; 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=NQsBpcgKVgYp7fXYDQVN06TvKGcdOIek7QQgIG6AozQ=; b=NOzV4yF015QMTYj3DnvZxvnwXwDMLfV1Z3XhqqlrVUSXk1UDRPYrWcQ1QcQJsuJ7+f 14Ca1Btkxom5pn4gpMKG2LAJd98MP3UnbVb67+6jvfot+Gh7qWEDQ0y/xnUfQ5emUnGN +kUUH6H9SpNDtFYXlqJmaqcefOFOjxM5vALq1WjFKyBUVdLRGOOGBZABRmS+3/rrhIwT B8V1ImwZLYlXGRYrhZAh9BH8bnjoQP3Mhz+LCIiLcf9uk6kWFSoBDfJqZWgLY4mXVkbE GbHJosYv8WhWGzU2zGwvCV9pqdJQfZJa6yyYwrm92ecJ0/xfJiRSHQBTW6vkKHYtJllf FPnQ== X-Gm-Message-State: ABy/qLY5ma3NNqGjEs+mhKvt/4PNokuO4seuvDqr2qXPiQd0vk3VwF/l SzvrXixNaZ749bLJ595I4cDMd3+hZbq5SdZxDFD54Q== X-Received: by 2002:a05:6000:4e4:b0:313:f61c:42ab with SMTP id cr4-20020a05600004e400b00313f61c42abmr9882143wrb.56.1688927407407; Sun, 09 Jul 2023 11:30:07 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.30.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:30:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Daniel Henrique Barboza Subject: [PULL 18/37] target/ppc: Use aesdec_ISB_ISR_AK_IMC Date: Sun, 9 Jul 2023 19:28:48 +0100 Message-Id: <20230709182934.309468-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x433.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This implements the VNCIPHER instruction. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- target/ppc/int_helper.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index 1e477924b7..834da80fe3 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -2947,22 +2947,11 @@ void helper_vcipherlast(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) void helper_vncipher(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) { - /* This differs from what is written in ISA V2.07. The RTL is */ - /* incorrect and will be fixed in V2.07B. */ - int i; - ppc_avr_t tmp; + AESState *ad = (AESState *)r; + AESState *st = (AESState *)a; + AESState *rk = (AESState *)b; - VECTOR_FOR_INORDER_I(i, u8) { - tmp.VsrB(i) = b->VsrB(i) ^ AES_isbox[a->VsrB(AES_ishifts[i])]; - } - - VECTOR_FOR_INORDER_I(i, u32) { - r->VsrW(i) = - AES_imc[tmp.VsrB(4 * i + 0)][0] ^ - AES_imc[tmp.VsrB(4 * i + 1)][1] ^ - AES_imc[tmp.VsrB(4 * i + 2)][2] ^ - AES_imc[tmp.VsrB(4 * i + 3)][3]; - } + aesdec_ISB_ISR_AK_IMC(ad, st, rk, true); } void helper_vncipherlast(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) From patchwork Sun Jul 9 18:28:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700866 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827732wrs; Sun, 9 Jul 2023 11:33:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlEqtzcP42hVFBChTLCqYvUZXLN8SEYO9VIpwQdIdvwZ7wTFHRbEB3idPBlZY6kTZOrFlHyx X-Received: by 2002:a05:620a:40e:b0:767:c9:c83 with SMTP id 14-20020a05620a040e00b0076700c90c83mr9172465qkp.12.1688927596950; Sun, 09 Jul 2023 11:33:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927596; cv=none; d=google.com; s=arc-20160816; b=n8f8NE8Kw2N2FcJ5KdgRw72lwRHyY7UGy0qBLIV0JqPnNmUYDLJlGXL1FCPiWU5Aw7 xAejNBhJg0uhHZ3zfG5UeW4rQMYRZVW7ZA7PzWWeJQJiPBm4HMINBM5+XNmfSx7y51CG hPO8slB9Qm2t+uh37CytaOe26ursZCbp+hsO2qZZY9AiKOt//DyejsAFmfgU+YzoYy6k mavuByqfJhwa6EHWaAb+Xb+YZb3r2qsFK0/LwFaCgyhWpvh3XJ6ZzBty4FIP8w341DrS fA9Q8dSVjTDq8gh1094CHTUIuGVKWpQpWCDgBcf8f7nbzP+8vCbMg5RZ/xhmBFMQO2Xj p4pQ== 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:cc:to :from:dkim-signature; bh=fCbxuyj6w2doHmBool/Ak6eLq+V5O+przb+5Ur/gE60=; fh=3IEiF/YPZ00TE94rna3Orj/L+TRFhpuNf7ElRJz3ubE=; b=R2qez8TlaBLzCsSXviUqwwzJRjdR4aJ/AJADvUsYCXENAQLUXDGSqn0SJ0y4wWT+UT rna6vDP88mEnr8ceVkacrZnYB2LPG4dbL4gNbPXnQHgdvq//cVRg1rj9SwQ5pD5pqMY5 HV7ANJwhy0VTZBpMHOtCxRE/N4+HCMG+qETk8yI5yv6uswkme12TAm0BSZoPUC4FC4Zv Q04/8LV310FpxrNIk36hHX0H/ryt+oT+Nb0qBbuxhMRgcIbVLXnZ4QPykVmJsoD1cO7E uKMD7dsSfyTUWi5iE9g/uiENmaHwA3QfofrT3DCEEmFRnVyja3E5l7D++2t3VDI1CNp9 zc0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y9Q5182s; 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 d24-20020a05620a137800b00766fce28b85si5057906qkl.53.2023.07.09.11.33.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:33:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y9Q5182s; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAn-0008U8-JW; Sun, 09 Jul 2023 14:30:17 -0400 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 1qIZAh-0008R8-E6 for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:11 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAf-00010A-HL for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:11 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fbea14706eso37892815e9.2 for ; Sun, 09 Jul 2023 11:30:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927408; x=1691519408; 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=fCbxuyj6w2doHmBool/Ak6eLq+V5O+przb+5Ur/gE60=; b=Y9Q5182sM/U0NJx95hFPNKJMI3sXAvJHxgPBZJb6BTeXzPpRxzqM374qjj++uaA/LQ BivzPcG7I7vCNWh4hbqb0YGCrzTz3KEg1jIyp0Bcmvr0iPG9r79LxnnYVUHNR9cCwq4/ uhm8TJiGmKMVsH7S6FsH4nE3HXSjOPkwWUNl96FVs2LMgu7OJADEkO8+dPPxNQHz1ZFa k/lkipAWR+hWs5f0xxigrOUjYNozdiFjkH2jtxbPyq/bi6KLi6oCMoyUiEfg6sVQMOg+ XSc6Jr3eNsbE14UR7/MJ19uidyrTVSl0MoUGvUOK4j8hLxaok9HOD7QPfl67ST0UtfPL p1Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927408; x=1691519408; 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=fCbxuyj6w2doHmBool/Ak6eLq+V5O+przb+5Ur/gE60=; b=lPhck7Iv6WRuFwy2+OJvKyWQupWMmH/9gL8TwuTZq+jhWSB7jWWegfyP9NBnw1is7l WdcI+jhfDqclPxmdlXHGY7nGDCLUPDUFYnk7LKRvr6qL1g4m73sdvk8zVXLBFgV8D3GM dodGnzV2OqKNpmq8vb/f5lZJqNM15AvvlpOOZ1+Xov86eQ1CryWKSgJ5KIb6pnMDajmw Y2Npd2U9j74D+JOcm6eY96b3a5WCEbfHbx8OghtQYHNSKgL55gkM8hHtJm+oH+aKWBrr Knruzi8EZ/KX8gbjBAGbVWTjd3xE0x+XswoFkPIJE0z+agTAXJSnK45T2qNl7tdIj1y4 wWuQ== X-Gm-Message-State: ABy/qLaRukmXlZef1Ub5WnNtJl52lW9dut19Na1qIwF6JCyE3KqXLiQS 9b/i15RKIkz87ozPO9VuoqsCJF1e47OclDuKUuYr5w== X-Received: by 2002:a7b:cb0c:0:b0:3fa:97ad:2ba5 with SMTP id u12-20020a7bcb0c000000b003fa97ad2ba5mr8232132wmj.31.1688927408279; Sun, 09 Jul 2023 11:30:08 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.30.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:30:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 19/37] target/i386: Use aesenc_SB_SR_AK Date: Sun, 9 Jul 2023 19:28:49 +0100 Message-Id: <20230709182934.309468-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32c.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This implements the AESENCLAST instruction. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/i386/ops_sse.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h index fb63af7afa..63fdecbe03 100644 --- a/target/i386/ops_sse.h +++ b/target/i386/ops_sse.h @@ -19,6 +19,7 @@ */ #include "crypto/aes.h" +#include "crypto/aes-round.h" #if SHIFT == 0 #define Reg MMXReg @@ -2202,12 +2203,12 @@ void glue(helper_aesenc, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) void glue(helper_aesenclast, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) { - int i; - Reg st = *v; - Reg rk = *s; + for (int i = 0; i < SHIFT; i++) { + AESState *ad = (AESState *)&d->ZMM_X(i); + AESState *st = (AESState *)&v->ZMM_X(i); + AESState *rk = (AESState *)&s->ZMM_X(i); - for (i = 0; i < 8 << SHIFT; i++) { - d->B(i) = rk.B(i) ^ (AES_sbox[st.B(AES_shifts[i & 15] + (i & ~15))]); + aesenc_SB_SR_AK(ad, st, rk, false); } } From patchwork Sun Jul 9 18:28:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700907 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4829867wrs; Sun, 9 Jul 2023 11:41:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlGVuvTcc+OqPiTq5jDAAsxgBmp+Q9H2AjfAO+CdEimAyJEtrxAZe94arGAn/hfMTqfBM/WY X-Received: by 2002:a05:620a:4416:b0:766:fb05:d7b4 with SMTP id v22-20020a05620a441600b00766fb05d7b4mr11191942qkp.57.1688928111557; Sun, 09 Jul 2023 11:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688928111; cv=none; d=google.com; s=arc-20160816; b=rh5PmMHXsV5rq4otmwiThQgWtGwKy08YCTcjDF5PMhwJgFkGT0Tl1Yn8uocLMVdSAT CHn2om3lFiD8V4ctl6RZbnOenknglHlNiyYQjxa24akOw1yzkefeeiRwvcQ0qQMvf5wC dzGtW5gKA1xMbmfoY5m/8qt5totiedgll6PO8Vb9D9bNDn/xaRh09O21qMUa/GZF6lHg 4iNscNUGdIZmQaDC0YbQR5V9yJ7kJiRgYhldKoKkw91hnoS+AVf6cMzh3tVrOdx1LRiE JFPuZrhBbIU1IVLS/i9rCjIx/Plvo21PfdNXaU7tQh3WeAo/i3fMeIA2kJVOL5Kb/oTC wXwQ== 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:cc:to :from:dkim-signature; bh=C1Ndh6I1tE5UeDqHZyfe4FN5fGzwUfKgv00siQ2QsL0=; fh=EsDPbv9tLFEVj/5Rbuvnb8455Ixt2+kw/VbBqBCm3P0=; b=03kIcZeGX7GJ/9c0NAbEmUIrR4a1GE4LLn4033pDhaTBPQKXXHRSJUxHucGZTxAHnL gzMkM4Gavf3QsBgqUWQQMHR9+EU3k+0KEJ7PuUTcy8T5mDhK0AQfwChtY998nW/Lzbe3 sor6uUiJ7JXMO6jsLLxEAE/pDZifwui0XpYw0fUKjTm5PUQ+75qZg8/rYqWLioQTqboK q4AA5WFWwSI/PhdKgW0/r+TbBz3UR3oYtltyL100On+UOU5hHV3GAUjQ6HN9MrlgDW7z b7/ckmwEfqdjfwQGYfrA2emeK/nvgtyoatm/07tZsK/93abSo3zBS0uHcgetsy9u5GIG U5LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jPDN9xZf; 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 dy33-20020a05620a60e100b00746af257e8fsi4726424qkb.714.2023.07.09.11.41.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:41:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jPDN9xZf; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAq-0008WU-5x; Sun, 09 Jul 2023 14:30:20 -0400 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 1qIZAj-0008Sl-Ex for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:13 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAh-00013z-8k for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:13 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fbc244d307so43912185e9.1 for ; Sun, 09 Jul 2023 11:30:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927410; x=1691519410; 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=C1Ndh6I1tE5UeDqHZyfe4FN5fGzwUfKgv00siQ2QsL0=; b=jPDN9xZfxi+4wLPYpkE1ZMOamKewzhn+K9ojLubUf0gpsiVG+k70qf5dMIQsgW3XPr BsoFKzkRzMuZqFER917PrZ/I3sUhuHIOZnRVYkddyppPk1wQmCfnFoQdtk3AcLR9clWd QLJpI8KdSWQQywu3MyKxb/ggga15u6iPfrkBqdEoVY6/E+iBWTp1vneex63ZDLha8Xg+ pWwyzRkBXunSs5f3vgY0TtFtkFl0TOTo/QToUL2jiBpIqDMNtmKk4wxe22CoQUI0RG5Y 4r2lcoxp9B8GyHExTXAbtJB9/XZAczqiMw+338/mHx+TogGxRta7fMdaHi8Jiqp9pMck AOWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927410; x=1691519410; 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=C1Ndh6I1tE5UeDqHZyfe4FN5fGzwUfKgv00siQ2QsL0=; b=dCAxpytnzxak42GwFtGAWyhytCWihnQ7ItO5HTd9rsXvxi2/fNrdjr3PKIckwwFzz2 LbZ5fnMkGMbp62M2fgWph06h7ZnyepT1G8ow2VSg33ynRkXWO/DiwylySajJ5R+6wlNp cWqY+fZfvqZGEWDq+tEuWNh+afY1oN9YvIxmJipGSPPz5l7cVJXWNBw/i4VybOj6u4a3 amujZ7bxhoefgcQ073wJqVRq0qBNW5qHwQwmybt7Xm8LXSk6JMdWzOvIuqvsLDDWcZ1e qQ3tHwi4tZpmC2eMR8AEiDTa6QGOLznB49eCHXZKedP5hhpaSuh31ymaD3foTNFK3SWC m+TQ== X-Gm-Message-State: ABy/qLanf80IorSXUz0wsBrWKPMZHLybHXa7zoiUvkCiyeHV3/oJVAq6 99C5TKQtgQ2wyz4c7FMT2KkOv4VQCflxYABZUdMXmA== X-Received: by 2002:a7b:c5d3:0:b0:3fa:934c:8356 with SMTP id n19-20020a7bc5d3000000b003fa934c8356mr3151501wmk.10.1688927410002; Sun, 09 Jul 2023 11:30:10 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:30:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Andreas Schwab Subject: [PATCH 20/45] linux-user: Make sure initial brk(0) is page-aligned Date: Sun, 9 Jul 2023 19:28:51 +0100 Message-Id: <20230709182934.309468-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x333.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Andreas Schwab Fixes: 86f04735ac ("linux-user: Fix brk() to release pages") Signed-off-by: Andreas Schwab Message-Id: Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson --- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8b12774fba..04e07cf261 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -806,7 +806,7 @@ static abi_ulong brk_page; void target_set_brk(abi_ulong new_brk) { - target_brk = new_brk; + target_brk = TARGET_PAGE_ALIGN(new_brk); brk_page = HOST_PAGE_ALIGN(target_brk); } From patchwork Sun Jul 9 18:28:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700886 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4828884wrs; Sun, 9 Jul 2023 11:37:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlHE77yByfd+PoNJPE26SmC1oWSHJkppn8Hmh95dLhFIQznwQ3v39AufC7wJMX2CZj6Yt75p X-Received: by 2002:a0c:b295:0:b0:636:abd2:3b57 with SMTP id r21-20020a0cb295000000b00636abd23b57mr7692058qve.20.1688927870375; Sun, 09 Jul 2023 11:37:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927870; cv=none; d=google.com; s=arc-20160816; b=PBJQiXvP/TKadw8Q/rZS7SklcJibZNPQSuqMe1KXOqoH1AYKTdw4iv3gOmQGa+J5/D WW9yuafsNYrz6os4v3Rn4LSkXlRhSZhWUNLnY1TJwBwDKKumoxcBUNUQhMt1ZXc9CKqp kEx4I9+/Azp3z2bfF9ICkHIhDvWeK9Vv3A/AePitGO4Ak6sk+YAYq83+leDoWrB1lWiC /NBcjV1T9rF4smfrfWkERVvNgCRgxDs73vM8yRmpFgJ0+sbMsMjWrEpL8rB8V4IIOdOt ZGE7JKpxY3UE5D/s6Pxir+b29HJ842VygLXXsysIw/si+KSJAuz3ZUnQ87l54osZHQ+i 9Rhg== 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:cc:to :from:dkim-signature; bh=2MU6soREEIeWjjQLlmK8RHmCnAP0c3qo3FFfRalqkkk=; fh=J9/n186FVRrl/nfQIqc4qEum8K7z3A9aFNkBgET3s3A=; b=I3QI3zU1YBpFPMiNzeGUWGyFHLiboG+uwydq3FlTt75WBdm3RzkzdiQ1EIKdyrI64r 8r6YOuLOSRcxR/JcW9FUTdbd3BQPTfuCqXP08wFt5gVNLt2zufr1L0Esasmt08mKUMDW LfLveuFU54qwj6OJZHtVhK5dYhQAdm5Sxh4GumRHutK+fXfOfpnNWcacz+eYwBv5o1nQ ejphE8sHuB2qEHHsh7BQj5J+hfxyf/pE9CWe6G5337F39K4oiN7xIn4AaV8JEEEJKq0h 0uyB+YaruIOmwiIQIjqsKEBSi+DgC99rkRDhIFbGjevZ8AtDjcukOJv/3ZqOv9+V+B14 CCjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pk9oLJSP; 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 z17-20020a0cda91000000b00635e113a0easi5010364qvj.41.2023.07.09.11.37.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:37:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pk9oLJSP; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZDm-0003EN-8J; Sun, 09 Jul 2023 14:33:22 -0400 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 1qIZDl-00033b-0j for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:21 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZDe-00049m-Cg for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:17 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-313f3a6db22so3764784f8f.3 for ; Sun, 09 Jul 2023 11:33:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927593; x=1691519593; 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=2MU6soREEIeWjjQLlmK8RHmCnAP0c3qo3FFfRalqkkk=; b=Pk9oLJSPF2CrU7EBPWwY5ZDvUNb97VmFJpkDfOQkNfZFRw2XTxhJqwgQ64DOGoAOSS 0rAl8BYkw2jIodbt0mS7CGuTUUQK+/FY/wGBip0sE/zRGhU3J65MP4E/IDEMQOXfxR24 cAx+mKCyCckk3gPDNs4I3v6goY5BUP5W1eN11u5HsP1xf+Y/WqIv3vAmcvsbSEeDxqxx GUXgpqdvjQD+rnC15h/plsqFvX13HEZfB1j8VkuzEBEBsRVOwgRadiDOE/pk2ml51Bf0 qcrDlK5vknqUih6gAlPSKAUvSMwyF2FQj0SCLjQZLsfrQAhBlxT/TeZKVesooB/K62F9 6vsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927593; x=1691519593; 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=2MU6soREEIeWjjQLlmK8RHmCnAP0c3qo3FFfRalqkkk=; b=VdT9CKeK1kW+w0eA8wYcmiVU+attSmz0/odVNDSgOtlnRsWveMS+Dgsw7TDx3dN2AF g8/02y3dDekadnt0VYc5LMdwoztbBre142D6KetNB1T1TGDvrTsV2YL1wwRAXtegn8CK e5IGWdaBTi/LNIWeFESIh9Vhai2QK7MgXwxXFnACIWpn7IHRCBAz01c/rJednc2GB/oP ASZtEM0vQ123JgcfeXPITlHXO80TqyzIyhcsFMS8dbDrq2tmJYYpnM2JMCNPdBjB+B/f ucDVBjttMamrRqNa0gWMD+XefR8OLpQkM+hey5csxNrmhewnXUnAGDhKRY532xBBzH6l hevw== X-Gm-Message-State: ABy/qLZXmxUcOoVJobtp8OG4CRdoNpWkKpe8bXo1Kcbh9dHgCF2B4daW jBltHzbsy8QnEi8P3Q9aW1JPE5jOLPX8U9yay41+5g== X-Received: by 2002:adf:efd1:0:b0:2ce:d84d:388f with SMTP id i17-20020adfefd1000000b002ced84d388fmr9753276wrp.40.1688927592630; Sun, 09 Jul 2023 11:33:12 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 21/45] linux-user: Fix formatting of mmap.c Date: Sun, 9 Jul 2023 19:28:53 +0100 Message-Id: <20230709182934.309468-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42c.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Fix all checkpatch.pl errors within mmap.c. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20230707204054.8792-5-richard.henderson@linaro.org> --- linux-user/mmap.c | 199 ++++++++++++++++++++++++++++------------------ 1 file changed, 122 insertions(+), 77 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 2692936773..639921dba0 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -56,10 +56,11 @@ void mmap_fork_start(void) void mmap_fork_end(int child) { - if (child) + if (child) { pthread_mutex_init(&mmap_mutex, NULL); - else + } else { pthread_mutex_unlock(&mmap_mutex); + } } /* @@ -203,40 +204,47 @@ static int mmap_frag(abi_ulong real_start, /* get the protection of the target pages outside the mapping */ prot1 = 0; - for(addr = real_start; addr < real_end; addr++) { - if (addr < start || addr >= end) + for (addr = real_start; addr < real_end; addr++) { + if (addr < start || addr >= end) { prot1 |= page_get_flags(addr); + } } if (prot1 == 0) { /* no page was there, so we allocate one */ void *p = mmap(host_start, qemu_host_page_size, prot, flags | MAP_ANONYMOUS, -1, 0); - if (p == MAP_FAILED) + if (p == MAP_FAILED) { return -1; + } prot1 = prot; } prot1 &= PAGE_BITS; prot_new = prot | prot1; if (!(flags & MAP_ANONYMOUS)) { - /* msync() won't work here, so we return an error if write is - possible while it is a shared mapping */ - if ((flags & MAP_TYPE) == MAP_SHARED && - (prot & PROT_WRITE)) + /* + * msync() won't work here, so we return an error if write is + * possible while it is a shared mapping. + */ + if ((flags & MAP_TYPE) == MAP_SHARED && (prot & PROT_WRITE)) { return -1; + } /* adjust protection to be able to read */ - if (!(prot1 & PROT_WRITE)) + if (!(prot1 & PROT_WRITE)) { mprotect(host_start, qemu_host_page_size, prot1 | PROT_WRITE); + } /* read the corresponding file data */ - if (pread(fd, g2h_untagged(start), end - start, offset) == -1) + if (pread(fd, g2h_untagged(start), end - start, offset) == -1) { return -1; + } /* put final protection */ - if (prot_new != (prot1 | PROT_WRITE)) + if (prot_new != (prot1 | PROT_WRITE)) { mprotect(host_start, qemu_host_page_size, prot_new); + } } else { if (prot_new != prot1) { mprotect(host_start, qemu_host_page_size, prot_new); @@ -265,8 +273,10 @@ abi_ulong mmap_next_start = TASK_UNMAPPED_BASE; unsigned long last_brk; -/* Subroutine of mmap_find_vma, used when we have pre-allocated a chunk - of guest address space. */ +/* + * Subroutine of mmap_find_vma, used when we have pre-allocated + * a chunk of guest address space. + */ static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size, abi_ulong align) { @@ -362,15 +372,17 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) * - shmat() with SHM_REMAP flag */ ptr = mmap(g2h_untagged(addr), size, PROT_NONE, - MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, -1, 0); + MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE, -1, 0); /* ENOMEM, if host address space has no memory */ if (ptr == MAP_FAILED) { return (abi_ulong)-1; } - /* Count the number of sequential returns of the same address. - This is used to modify the search algorithm below. */ + /* + * Count the number of sequential returns of the same address. + * This is used to modify the search algorithm below. + */ repeat = (ptr == prev ? repeat + 1 : 0); if (h2g_valid(ptr + size - 1)) { @@ -387,14 +399,18 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) /* The address is not properly aligned for the target. */ switch (repeat) { case 0: - /* Assume the result that the kernel gave us is the - first with enough free space, so start again at the - next higher target page. */ + /* + * Assume the result that the kernel gave us is the + * first with enough free space, so start again at the + * next higher target page. + */ addr = ROUND_UP(addr, align); break; case 1: - /* Sometimes the kernel decides to perform the allocation - at the top end of memory instead. */ + /* + * Sometimes the kernel decides to perform the allocation + * at the top end of memory instead. + */ addr &= -align; break; case 2: @@ -407,8 +423,10 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) break; } } else { - /* Since the result the kernel gave didn't fit, start - again at low memory. If any repetition, fail. */ + /* + * Since the result the kernel gave didn't fit, start + * again at low memory. If any repetition, fail. + */ addr = (repeat ? -1 : 0); } @@ -423,8 +441,10 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) return (abi_ulong)-1; } wrapped = 1; - /* Don't actually use 0 when wrapping, instead indicate - that we'd truly like an allocation in low memory. */ + /* + * Don't actually use 0 when wrapping, instead indicate + * that we'd truly like an allocation in low memory. + */ addr = (mmap_min_addr > TARGET_PAGE_SIZE ? TARGET_PAGE_ALIGN(mmap_min_addr) : TARGET_PAGE_SIZE); @@ -485,8 +505,10 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, real_start = start & qemu_host_page_mask; host_offset = offset & qemu_host_page_mask; - /* If the user is asking for the kernel to find a location, do that - before we truncate the length for mapping files below. */ + /* + * If the user is asking for the kernel to find a location, do that + * before we truncate the length for mapping files below. + */ if (!(flags & MAP_FIXED)) { host_len = len + offset - host_offset; host_len = HOST_PAGE_ALIGN(host_len); @@ -497,32 +519,36 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, } } - /* When mapping files into a memory area larger than the file, accesses - to pages beyond the file size will cause a SIGBUS. - - For example, if mmaping a file of 100 bytes on a host with 4K pages - emulating a target with 8K pages, the target expects to be able to - access the first 8K. But the host will trap us on any access beyond - 4K. - - When emulating a target with a larger page-size than the hosts, we - may need to truncate file maps at EOF and add extra anonymous pages - up to the targets page boundary. */ - + /* + * When mapping files into a memory area larger than the file, accesses + * to pages beyond the file size will cause a SIGBUS. + * + * For example, if mmaping a file of 100 bytes on a host with 4K pages + * emulating a target with 8K pages, the target expects to be able to + * access the first 8K. But the host will trap us on any access beyond + * 4K. + * + * When emulating a target with a larger page-size than the hosts, we + * may need to truncate file maps at EOF and add extra anonymous pages + * up to the targets page boundary. + */ if ((qemu_real_host_page_size() < qemu_host_page_size) && !(flags & MAP_ANONYMOUS)) { struct stat sb; - if (fstat (fd, &sb) == -1) - goto fail; + if (fstat(fd, &sb) == -1) { + goto fail; + } - /* Are we trying to create a map beyond EOF?. */ - if (offset + len > sb.st_size) { - /* If so, truncate the file map at eof aligned with - the hosts real pagesize. Additional anonymous maps - will be created beyond EOF. */ - len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset); - } + /* Are we trying to create a map beyond EOF?. */ + if (offset + len > sb.st_size) { + /* + * If so, truncate the file map at eof aligned with + * the hosts real pagesize. Additional anonymous maps + * will be created beyond EOF. + */ + len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset); + } } if (!(flags & MAP_FIXED)) { @@ -532,9 +558,11 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, host_len = len + offset - host_offset; host_len = HOST_PAGE_ALIGN(host_len); - /* Note: we prefer to control the mapping address. It is - especially important if qemu_host_page_size > - qemu_real_host_page_size */ + /* + * Note: we prefer to control the mapping address. It is + * especially important if qemu_host_page_size > + * qemu_real_host_page_size. + */ p = mmap(g2h_untagged(start), host_len, host_prot, flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); if (p == MAP_FAILED) { @@ -572,45 +600,52 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, goto fail; } - /* worst case: we cannot map the file because the offset is not - aligned, so we read it */ + /* + * worst case: we cannot map the file because the offset is not + * aligned, so we read it + */ if (!(flags & MAP_ANONYMOUS) && (offset & ~qemu_host_page_mask) != (start & ~qemu_host_page_mask)) { - /* msync() won't work here, so we return an error if write is - possible while it is a shared mapping */ - if ((flags & MAP_TYPE) == MAP_SHARED && - (host_prot & PROT_WRITE)) { + /* + * msync() won't work here, so we return an error if write is + * possible while it is a shared mapping + */ + if ((flags & MAP_TYPE) == MAP_SHARED && (host_prot & PROT_WRITE)) { errno = EINVAL; goto fail; } retaddr = target_mmap(start, len, target_prot | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (retaddr == -1) + if (retaddr == -1) { goto fail; - if (pread(fd, g2h_untagged(start), len, offset) == -1) + } + if (pread(fd, g2h_untagged(start), len, offset) == -1) { goto fail; + } if (!(host_prot & PROT_WRITE)) { ret = target_mprotect(start, len, target_prot); assert(ret == 0); } goto the_end; } - + /* handle the start of the mapping */ if (start > real_start) { if (real_end == real_start + qemu_host_page_size) { /* one single host page */ ret = mmap_frag(real_start, start, end, host_prot, flags, fd, offset); - if (ret == -1) + if (ret == -1) { goto fail; + } goto the_end1; } ret = mmap_frag(real_start, start, real_start + qemu_host_page_size, host_prot, flags, fd, offset); - if (ret == -1) + if (ret == -1) { goto fail; + } real_start += qemu_host_page_size; } /* handle the end of the mapping */ @@ -619,8 +654,9 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, real_end - qemu_host_page_size, end, host_prot, flags, fd, offset + real_end - qemu_host_page_size - start); - if (ret == -1) + if (ret == -1) { goto fail; + } real_end -= qemu_host_page_size; } @@ -628,14 +664,16 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, if (real_start < real_end) { void *p; unsigned long offset1; - if (flags & MAP_ANONYMOUS) + if (flags & MAP_ANONYMOUS) { offset1 = 0; - else + } else { offset1 = offset + real_start - start; + } p = mmap(g2h_untagged(real_start), real_end - real_start, host_prot, flags, fd, offset1); - if (p == MAP_FAILED) + if (p == MAP_FAILED) { goto fail; + } passthrough_start = real_start; passthrough_end = real_end; } @@ -697,16 +735,18 @@ static void mmap_reserve(abi_ulong start, abi_ulong size) } end = real_end; } - if (prot != 0) + if (prot != 0) { real_start += qemu_host_page_size; + } } if (end < real_end) { prot = 0; for (addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) { prot |= page_get_flags(addr); } - if (prot != 0) + if (prot != 0) { real_end -= qemu_host_page_size; + } } if (real_start != real_end) { mmap(g2h_untagged(real_start), real_end - real_start, PROT_NONE, @@ -722,8 +762,9 @@ int target_munmap(abi_ulong start, abi_ulong len) trace_target_munmap(start, len); - if (start & ~TARGET_PAGE_MASK) + if (start & ~TARGET_PAGE_MASK) { return -TARGET_EINVAL; + } len = TARGET_PAGE_ALIGN(len); if (len == 0 || !guest_range_valid_untagged(start, len)) { return -TARGET_EINVAL; @@ -737,25 +778,27 @@ int target_munmap(abi_ulong start, abi_ulong len) if (start > real_start) { /* handle host page containing start */ prot = 0; - for(addr = real_start; addr < start; addr += TARGET_PAGE_SIZE) { + for (addr = real_start; addr < start; addr += TARGET_PAGE_SIZE) { prot |= page_get_flags(addr); } if (real_end == real_start + qemu_host_page_size) { - for(addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) { + for (addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) { prot |= page_get_flags(addr); } end = real_end; } - if (prot != 0) + if (prot != 0) { real_start += qemu_host_page_size; + } } if (end < real_end) { prot = 0; - for(addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) { + for (addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) { prot |= page_get_flags(addr); } - if (prot != 0) + if (prot != 0) { real_end -= qemu_host_page_size; + } } ret = 0; @@ -798,8 +841,10 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, flags, g2h_untagged(new_addr)); if (reserved_va && host_addr != MAP_FAILED) { - /* If new and old addresses overlap then the above mremap will - already have failed with EINVAL. */ + /* + * If new and old addresses overlap then the above mremap will + * already have failed with EINVAL. + */ mmap_reserve(old_addr, old_size); } } else if (flags & MREMAP_MAYMOVE) { From patchwork Sun Jul 9 18:28:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700910 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4830044wrs; Sun, 9 Jul 2023 11:42:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlHCqvtbSyaSJj3ntHZy1k2Jh5CHvIicvRTZ5MSopYDcmebVM8valqEUlXowpy4iLeCO8LjX X-Received: by 2002:a05:6214:d6a:b0:636:695:c84c with SMTP id 10-20020a0562140d6a00b006360695c84cmr18500296qvs.20.1688928156139; Sun, 09 Jul 2023 11:42:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688928156; cv=none; d=google.com; s=arc-20160816; b=mPYASmxVifn5v1omFuS75S/PHavGsfP3aUEBlkzs7CPOkSkeuL+CUmipyY4hYSfu1U oaUi2HHYl8aRu9X+R4CR4Hes2LfgiXHlBvnSe2+NZsg8E5VTitkc0Ff+L2EEEuS5CFdI sOikuF5nbxldkdKgaSs07G9G+lJulsCw03MSKVmXosZjaCHmfkJRfFNHu2xwq6GNpATu PNzbFEbqMbDPM/TmjHYZN5qlRQmmjBzPNX8F5pXg+11p913JhSrYbxL0Lb3v2t86daMb x/ReY/+qubuiWEW1TGuFs4+E6QYej9fPe6tF8V4D+Pww8p9F2ZlIFjqYYi+uAwV2DN7O xFVg== 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:cc:to :from:dkim-signature; bh=vBbRyJEaYCF6DplERXnYlyOqNcFvmMhKu7a8Ju7Ez3M=; fh=3IEiF/YPZ00TE94rna3Orj/L+TRFhpuNf7ElRJz3ubE=; b=S3Xb8jHPzx+1ZpPdebyR1QRrspuHlTnwTlM2zPkawvSl6P1TWd06dU9tuhzhA6D6yD 9vV91NEk7d3r4wwyfIoJEOoha6dywEUysTyeMOts3KH54908a0u+ya5sAgUlFuUzZljB uYhu5TlzLBhdHuzeosvehsN5u7IikC4TPbcvu+3E0L+S6SVyvuF6eJoZuSvE1ZbyuL9O LNM0W0b+GJdDxMyjUtjmnl4K1ofhePBJUjuk9ckFn8lPMYVPEPOPDIcJzrcA6rF+4be9 uy9M9OG03cH6qb/KvsujGbbfwIeoK/eOzXWalmnh3a4GSVA5j8GaTwrAVjuoT3lLgAZ6 4gUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ryBrjVtC; 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 r10-20020a0ccc0a000000b00626322e9aa9si4798399qvk.50.2023.07.09.11.42.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:42:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ryBrjVtC; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZDs-0003RP-8N; Sun, 09 Jul 2023 14:33:33 -0400 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 1qIZDl-00033c-1Z for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:21 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZDg-0004A1-KT for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:18 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3fbc656873eso49182145e9.1 for ; Sun, 09 Jul 2023 11:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927595; x=1691519595; 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=vBbRyJEaYCF6DplERXnYlyOqNcFvmMhKu7a8Ju7Ez3M=; b=ryBrjVtCzcG5Bxe66Yg3RhXI1AJDqQ5I53JXZsqA92sGwkS2tzrfYPSy+9pyDpmb7o bLkxrUNXeDaX3Z6qgH4465ZwQYpaF6Zb9V6XDptnt7B4DCyaESvC4XHHHGnQBlsp7xmw LY/2tijGhCc1AtVkuxzsR7th7mOJtGKM86nB1YIZCkzuJm/q3xLt/U233bgmuw77p2O/ gwTzbHh0xxnRLMdJSWO46e59TV7Y6HpL7qNHF2NkdlNxotwBGFvLqjXnmBsUrOaXKg/j fd1VrPacoZLFm7MxUYSi5F6e8IeHE+J3qrNFlYzTdFWEwQu/XycC5f5SzX1AVPHf/2LK M/WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927595; x=1691519595; 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=vBbRyJEaYCF6DplERXnYlyOqNcFvmMhKu7a8Ju7Ez3M=; b=PbqqYJQy8wEMgmSEfHxZbqN62F4Bi04D6bRWAwChrZq12roECCTB+TxMt88pQGnX1K 7W1q9Dg3RfrtSBzRsHFCPkHcKpv9PKHlc6nQLkfi1XlSEf67yf8GUIbieeaRP6cl5dQx CUp3suMPC5teYfpTF9p3GtV6Adtd2du1bTAd1aTxMhlD2caAFfSvIYhFTd6Rw0pp7Bm9 Z0zK6GiKWWvVeGwCPZeqv6jdb+BqsNVzFLz209KLItEFp0Tm3h45Bz1gJi6jkbUMqoLi IoHHuz0Xhzx62RvU6uKOYG1xw9FzEVf8yaMmw2A30eMbx9uAF9h913JKqY6p2/Q1LytN pdMA== X-Gm-Message-State: ABy/qLZhsRZC2wLX31wtaleYsabMV1FFuFos87zoJJvRBlbchewUwhsp 0fJQnHFVBifn2QuqtkrBb3CMxwqpSuwndSRoagOfEQ== X-Received: by 2002:a5d:6a08:0:b0:315:8a80:329e with SMTP id m8-20020a5d6a08000000b003158a80329emr8433162wru.40.1688927595095; Sun, 09 Jul 2023 11:33:15 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 22/37] target/i386: Use aesenc_SB_SR_MC_AK Date: Sun, 9 Jul 2023 19:28:56 +0100 Message-Id: <20230709182934.309468-45-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32a.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This implements the AESENC instruction. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/i386/ops_sse.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h index 893913ebf8..93a4e0cf16 100644 --- a/target/i386/ops_sse.h +++ b/target/i386/ops_sse.h @@ -2188,16 +2188,12 @@ void glue(helper_aesdeclast, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) void glue(helper_aesenc, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) { - int i; - Reg st = *v; - Reg rk = *s; + for (int i = 0; i < SHIFT; i++) { + AESState *ad = (AESState *)&d->ZMM_X(i); + AESState *st = (AESState *)&v->ZMM_X(i); + AESState *rk = (AESState *)&s->ZMM_X(i); - for (i = 0 ; i < 2 << SHIFT ; i++) { - int j = i & 3; - d->L(i) = rk.L(i) ^ bswap32(AES_Te0[st.B(AES_shifts[4 * j + 0])] ^ - AES_Te1[st.B(AES_shifts[4 * j + 1])] ^ - AES_Te2[st.B(AES_shifts[4 * j + 2])] ^ - AES_Te3[st.B(AES_shifts[4 * j + 3])]); + aesenc_SB_SR_MC_AK(ad, st, rk, false); } } From patchwork Sun Jul 9 18:28:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700869 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827865wrs; Sun, 9 Jul 2023 11:33:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlFwjjwyPmSaCOndnkCVXDdKARj0K8U7bSRGRnHSv2E4RfdAGDwO+YiFGhi2DszlfmP6Z0J2 X-Received: by 2002:ac8:7f15:0:b0:3ff:3f17:b4cd with SMTP id f21-20020ac87f15000000b003ff3f17b4cdmr13801444qtk.22.1688927626646; Sun, 09 Jul 2023 11:33:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927626; cv=none; d=google.com; s=arc-20160816; b=zujGSPKto/IyXzwI6SzbKiFixqoEtlj7vSIJTUuWgFokQeUjhNlEdRnXWV5kJKzj68 2XaW5lHQy7bBV96HVnfvh3i2+7QO3HgmE+jwC62TNuzdKNOeOQSazONhWlH0oFtjZeQS UIBVktkXpv7J5Pvg23bz5poaPJlem0YTDW7zHhkKQFaU/rQPqp3w5KAgjhmJSieFY8b2 ciMG+Ajk7xwLa/7fgvTfu7RAy/fvHDn/yAGviXUQuqJdyr+fJ6bTIYRQMKSE1bX2tDF1 LTdnurRLdhfGfEIIrNek8cXtwPunGoMRHU1iVeTgCYOuVcCYmAxY1hn73vIyHVO5pUY5 kfGg== 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:cc:to :from:dkim-signature; bh=v53BpocOSkZq13xiAuKy1Z69SsuVPyzPYM9KNeUZOtU=; fh=Q/KtKvobZ4aKW4dKNmZSl6eueXWWlvOAYdnlEZxfDJk=; b=SOWU4a2wvKcP5Uutzi00OxVAYlT4LmK+QflamCBiisrdBF8Oq4oO0wF85AZPwzi5PZ 5Hs3vjtma1MIu9HHsX1cm2/f/hufmJXGDXY1IH0/llPDjyLamOz2DTovwKqAJrJIWAut eSrt7zY8HTyDruiyFVKm+UQ2mp6surDv2kY9lAutGlPAMlMFJg2fnB6wBtC+/nFPAmCA U7nu3cwhKrgI0YiSj0OMj1CNYkLoNm0ooWMP5P9e/9KQ2j94NqQwd0zApQ6yC6JmCTNU BvI7Th/98QkP5Sxr3bfcaaCIELD7KB1UaMZ2AB1wfb3//vfLcOCdVy864zDMmpViG9BM 9ypw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nX6u4/50"; 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 s19-20020a05622a019300b0040349317cf3si4761794qtw.599.2023.07.09.11.33.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:33:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nX6u4/50"; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZE2-0003jC-IL; Sun, 09 Jul 2023 14:33:38 -0400 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 1qIZDl-00033h-3H for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:21 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZDh-0004AM-66 for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:19 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fbc6ab5ff5so39279285e9.1 for ; Sun, 09 Jul 2023 11:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927596; x=1691519596; 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=v53BpocOSkZq13xiAuKy1Z69SsuVPyzPYM9KNeUZOtU=; b=nX6u4/501AaLKllQdCgFDRqJbCP3hJhwBSzfezPMfcvUh9Q6mlaVL+grIMuKIPAqk3 vj06KaN8ZBb0fAVkQyoNjp+OELTxPnU6CAAfKQBHajILAYcaGbEtalKtTGFMoDoDMG+J AuXzNiLhS11JEPYBspuu0GzPp43T/ZD9+AXjQF+ybMoTpA6h1coQSiqrN28Ia7v7xeoy rxLzhK0EVepG9jk+j7oZeQr5/um4eTb1LCmvC6ocLIaip9vmCJla51hxxZ4Z0pRwFF77 YmUziVh8KEbID7cP2SqNELev1deMshQX7AW60NMlJL/Dem+HHHYYDcBG5texgMWERwa3 jD2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927596; x=1691519596; 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=v53BpocOSkZq13xiAuKy1Z69SsuVPyzPYM9KNeUZOtU=; b=hM6oHn1tcOsi6koQoSNrDmUY0acePCgN9kqPfgFaqnIew9n9H2RoDrxeYtV8NV68bH RHxfig7M5o7Pe1c1e5KGNEXDA1n1OTdzivLFncaGPCTF6gxLeux7EG/7NHoOcrmXb9JK 5Ps2dAWppCUZSRTWoZUJA1GHp/MHr0CxtLHWSqYQM9CgOes5/umdwXWywe09EiEHzZWg pp15R5CDJ4XhEOFl4EVYfgxZWoBLXkMOWWcRVrV16h9ddDBUqfquJjklMVBYLEJBGT2n s+vv26s+IUzEc4i1UW6h9bRfgs4oKDf+rZjIAB9Jer9Gjfjwxts0Be+GFPiuXPfj5Yqr /wOg== X-Gm-Message-State: ABy/qLY3hKJD/1njaAbC+bu/N7YaEYqNDtoGG9o/Ojpyy2v4cF+74cLN b9YllyPomERIRHTPzKCC0uIcM+TVpKUqQ/0MJT3zQA== X-Received: by 2002:a5d:6a4d:0:b0:314:553e:c590 with SMTP id t13-20020a5d6a4d000000b00314553ec590mr8748080wrw.5.1688927595863; Sun, 09 Jul 2023 11:33:15 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH 23/45] linux-user: Split TARGET_MAP_* out of syscall_defs.h Date: Sun, 9 Jul 2023 19:28:57 +0100 Message-Id: <20230709182934.309468-46-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x336.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Move the values into the per-target target_mman.h headers Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20230707204054.8792-7-richard.henderson@linaro.org> --- linux-user/alpha/target_mman.h | 13 +++++ linux-user/generic/target_mman.h | 54 ++++++++++++++++++++ linux-user/hppa/target_mman.h | 10 ++++ linux-user/mips/target_mman.h | 16 ++++++ linux-user/mips64/target_mman.h | 2 +- linux-user/ppc/target_mman.h | 8 +++ linux-user/sparc/target_mman.h | 9 ++++ linux-user/syscall_defs.h | 85 +------------------------------- linux-user/xtensa/target_mman.h | 16 ++++++ 9 files changed, 128 insertions(+), 85 deletions(-) diff --git a/linux-user/alpha/target_mman.h b/linux-user/alpha/target_mman.h index 051544f5ab..6bb03e7336 100644 --- a/linux-user/alpha/target_mman.h +++ b/linux-user/alpha/target_mman.h @@ -1,6 +1,19 @@ #ifndef ALPHA_TARGET_MMAN_H #define ALPHA_TARGET_MMAN_H +#define TARGET_MAP_ANONYMOUS 0x10 +#define TARGET_MAP_FIXED 0x100 +#define TARGET_MAP_GROWSDOWN 0x01000 +#define TARGET_MAP_DENYWRITE 0x02000 +#define TARGET_MAP_EXECUTABLE 0x04000 +#define TARGET_MAP_LOCKED 0x08000 +#define TARGET_MAP_NORESERVE 0x10000 +#define TARGET_MAP_POPULATE 0x20000 +#define TARGET_MAP_NONBLOCK 0x40000 +#define TARGET_MAP_STACK 0x80000 +#define TARGET_MAP_HUGETLB 0x100000 +#define TARGET_MAP_FIXED_NOREPLACE 0x200000 + #define TARGET_MADV_DONTNEED 6 #define TARGET_MS_ASYNC 1 diff --git a/linux-user/generic/target_mman.h b/linux-user/generic/target_mman.h index 32bf1a52d0..7b888fb7f8 100644 --- a/linux-user/generic/target_mman.h +++ b/linux-user/generic/target_mman.h @@ -1,6 +1,60 @@ #ifndef LINUX_USER_TARGET_MMAN_H #define LINUX_USER_TARGET_MMAN_H +/* These are defined in linux/mmap.h */ +#define TARGET_MAP_SHARED 0x01 +#define TARGET_MAP_PRIVATE 0x02 +#define TARGET_MAP_SHARED_VALIDATE 0x03 + +/* 0x0100 - 0x4000 flags are defined in asm-generic/mman.h */ +#ifndef TARGET_MAP_GROWSDOWN +#define TARGET_MAP_GROWSDOWN 0x0100 +#endif +#ifndef TARGET_MAP_DENYWRITE +#define TARGET_MAP_DENYWRITE 0x0800 +#endif +#ifndef TARGET_MAP_EXECUTABLE +#define TARGET_MAP_EXECUTABLE 0x1000 +#endif +#ifndef TARGET_MAP_LOCKED +#define TARGET_MAP_LOCKED 0x2000 +#endif +#ifndef TARGET_MAP_NORESERVE +#define TARGET_MAP_NORESERVE 0x4000 +#endif + +/* Other MAP flags are defined in asm-generic/mman-common.h */ +#ifndef TARGET_MAP_TYPE +#define TARGET_MAP_TYPE 0x0f +#endif +#ifndef TARGET_MAP_FIXED +#define TARGET_MAP_FIXED 0x10 +#endif +#ifndef TARGET_MAP_ANONYMOUS +#define TARGET_MAP_ANONYMOUS 0x20 +#endif +#ifndef TARGET_MAP_POPULATE +#define TARGET_MAP_POPULATE 0x008000 +#endif +#ifndef TARGET_MAP_NONBLOCK +#define TARGET_MAP_NONBLOCK 0x010000 +#endif +#ifndef TARGET_MAP_STACK +#define TARGET_MAP_STACK 0x020000 +#endif +#ifndef TARGET_MAP_HUGETLB +#define TARGET_MAP_HUGETLB 0x040000 +#endif +#ifndef TARGET_MAP_SYNC +#define TARGET_MAP_SYNC 0x080000 +#endif +#ifndef TARGET_MAP_FIXED_NOREPLACE +#define TARGET_MAP_FIXED_NOREPLACE 0x100000 +#endif +#ifndef TARGET_MAP_UNINITIALIZED +#define TARGET_MAP_UNINITIALIZED 0x4000000 +#endif + #ifndef TARGET_MADV_NORMAL #define TARGET_MADV_NORMAL 0 #endif diff --git a/linux-user/hppa/target_mman.h b/linux-user/hppa/target_mman.h index f9b6b97032..97f87d042a 100644 --- a/linux-user/hppa/target_mman.h +++ b/linux-user/hppa/target_mman.h @@ -1,6 +1,16 @@ #ifndef HPPA_TARGET_MMAN_H #define HPPA_TARGET_MMAN_H +#define TARGET_MAP_TYPE 0x2b +#define TARGET_MAP_FIXED 0x04 +#define TARGET_MAP_ANONYMOUS 0x10 +#define TARGET_MAP_GROWSDOWN 0x8000 +#define TARGET_MAP_POPULATE 0x10000 +#define TARGET_MAP_NONBLOCK 0x20000 +#define TARGET_MAP_STACK 0x40000 +#define TARGET_MAP_HUGETLB 0x80000 +#define TARGET_MAP_UNINITIALIZED 0 + #define TARGET_MADV_MERGEABLE 65 #define TARGET_MADV_UNMERGEABLE 66 #define TARGET_MADV_HUGEPAGE 67 diff --git a/linux-user/mips/target_mman.h b/linux-user/mips/target_mman.h index e7ba6070fe..cd566c24b6 100644 --- a/linux-user/mips/target_mman.h +++ b/linux-user/mips/target_mman.h @@ -1 +1,17 @@ +#ifndef MIPS_TARGET_MMAN_H +#define MIPS_TARGET_MMAN_H + +#define TARGET_MAP_NORESERVE 0x0400 +#define TARGET_MAP_ANONYMOUS 0x0800 +#define TARGET_MAP_GROWSDOWN 0x1000 +#define TARGET_MAP_DENYWRITE 0x2000 +#define TARGET_MAP_EXECUTABLE 0x4000 +#define TARGET_MAP_LOCKED 0x8000 +#define TARGET_MAP_POPULATE 0x10000 +#define TARGET_MAP_NONBLOCK 0x20000 +#define TARGET_MAP_STACK 0x40000 +#define TARGET_MAP_HUGETLB 0x80000 + #include "../generic/target_mman.h" + +#endif diff --git a/linux-user/mips64/target_mman.h b/linux-user/mips64/target_mman.h index e7ba6070fe..7bdc47d902 100644 --- a/linux-user/mips64/target_mman.h +++ b/linux-user/mips64/target_mman.h @@ -1 +1 @@ -#include "../generic/target_mman.h" +#include "../mips/target_mman.h" diff --git a/linux-user/ppc/target_mman.h b/linux-user/ppc/target_mman.h index e7ba6070fe..67cc218f2e 100644 --- a/linux-user/ppc/target_mman.h +++ b/linux-user/ppc/target_mman.h @@ -1 +1,9 @@ +#ifndef PPC_TARGET_MMAN_H +#define PPC_TARGET_MMAN_H + +#define TARGET_MAP_NORESERVE 0x40 +#define TARGET_MAP_LOCKED 0x80 + #include "../generic/target_mman.h" + +#endif diff --git a/linux-user/sparc/target_mman.h b/linux-user/sparc/target_mman.h index e7ba6070fe..9bad99c852 100644 --- a/linux-user/sparc/target_mman.h +++ b/linux-user/sparc/target_mman.h @@ -1 +1,10 @@ +#ifndef SPARC_TARGET_MMAN_H +#define SPARC_TARGET_MMAN_H + +#define TARGET_MAP_NORESERVE 0x40 +#define TARGET_MAP_LOCKED 0x100 +#define TARGET_MAP_GROWSDOWN 0x0200 + #include "../generic/target_mman.h" + +#endif diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index c8ffb4f785..041105b7a7 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1238,90 +1238,7 @@ struct target_winsize { #define TARGET_PROT_MTE 0x20 #endif -/* Common */ -#define TARGET_MAP_SHARED 0x01 /* Share changes */ -#define TARGET_MAP_PRIVATE 0x02 /* Changes are private */ -#if defined(TARGET_HPPA) -#define TARGET_MAP_TYPE 0x03 /* Mask for type of mapping */ -#else -#define TARGET_MAP_TYPE 0x0f /* Mask for type of mapping */ -#endif - -/* Target specific */ -#if defined(TARGET_MIPS) -#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */ -#define TARGET_MAP_ANONYMOUS 0x0800 /* don't use a file */ -#define TARGET_MAP_GROWSDOWN 0x1000 /* stack-like segment */ -#define TARGET_MAP_DENYWRITE 0x2000 /* ETXTBSY */ -#define TARGET_MAP_EXECUTABLE 0x4000 /* mark it as an executable */ -#define TARGET_MAP_LOCKED 0x8000 /* pages are locked */ -#define TARGET_MAP_NORESERVE 0x0400 /* don't check for reservations */ -#define TARGET_MAP_POPULATE 0x10000 /* populate (prefault) pagetables */ -#define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */ -#define TARGET_MAP_STACK 0x40000 /* ignored */ -#define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */ -#elif defined(TARGET_PPC) -#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */ -#define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */ -#define TARGET_MAP_GROWSDOWN 0x0100 /* stack-like segment */ -#define TARGET_MAP_DENYWRITE 0x0800 /* ETXTBSY */ -#define TARGET_MAP_EXECUTABLE 0x1000 /* mark it as an executable */ -#define TARGET_MAP_LOCKED 0x0080 /* pages are locked */ -#define TARGET_MAP_NORESERVE 0x0040 /* don't check for reservations */ -#define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ -#define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */ -#define TARGET_MAP_STACK 0x20000 /* ignored */ -#define TARGET_MAP_HUGETLB 0x40000 /* create a huge page mapping */ -#elif defined(TARGET_ALPHA) -#define TARGET_MAP_ANONYMOUS 0x10 /* don't use a file */ -#define TARGET_MAP_FIXED 0x100 /* Interpret addr exactly */ -#define TARGET_MAP_GROWSDOWN 0x01000 /* stack-like segment */ -#define TARGET_MAP_DENYWRITE 0x02000 /* ETXTBSY */ -#define TARGET_MAP_EXECUTABLE 0x04000 /* mark it as an executable */ -#define TARGET_MAP_LOCKED 0x08000 /* lock the mapping */ -#define TARGET_MAP_NORESERVE 0x10000 /* no check for reservations */ -#define TARGET_MAP_POPULATE 0x20000 /* pop (prefault) pagetables */ -#define TARGET_MAP_NONBLOCK 0x40000 /* do not block on IO */ -#define TARGET_MAP_STACK 0x80000 /* ignored */ -#define TARGET_MAP_HUGETLB 0x100000 /* create a huge page mapping */ -#elif defined(TARGET_HPPA) -#define TARGET_MAP_ANONYMOUS 0x10 /* don't use a file */ -#define TARGET_MAP_FIXED 0x04 /* Interpret addr exactly */ -#define TARGET_MAP_GROWSDOWN 0x08000 /* stack-like segment */ -#define TARGET_MAP_DENYWRITE 0x00800 /* ETXTBSY */ -#define TARGET_MAP_EXECUTABLE 0x01000 /* mark it as an executable */ -#define TARGET_MAP_LOCKED 0x02000 /* lock the mapping */ -#define TARGET_MAP_NORESERVE 0x04000 /* no check for reservations */ -#define TARGET_MAP_POPULATE 0x10000 /* pop (prefault) pagetables */ -#define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */ -#define TARGET_MAP_STACK 0x40000 /* ignored */ -#define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */ -#elif defined(TARGET_XTENSA) -#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */ -#define TARGET_MAP_ANONYMOUS 0x0800 /* don't use a file */ -#define TARGET_MAP_GROWSDOWN 0x1000 /* stack-like segment */ -#define TARGET_MAP_DENYWRITE 0x2000 /* ETXTBSY */ -#define TARGET_MAP_EXECUTABLE 0x4000 /* mark it as an executable */ -#define TARGET_MAP_LOCKED 0x8000 /* pages are locked */ -#define TARGET_MAP_NORESERVE 0x0400 /* don't check for reservations */ -#define TARGET_MAP_POPULATE 0x10000 /* populate (prefault) pagetables */ -#define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */ -#define TARGET_MAP_STACK 0x40000 -#define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */ -#else -#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */ -#define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */ -#define TARGET_MAP_GROWSDOWN 0x0100 /* stack-like segment */ -#define TARGET_MAP_DENYWRITE 0x0800 /* ETXTBSY */ -#define TARGET_MAP_EXECUTABLE 0x1000 /* mark it as an executable */ -#define TARGET_MAP_LOCKED 0x2000 /* pages are locked */ -#define TARGET_MAP_NORESERVE 0x4000 /* don't check for reservations */ -#define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ -#define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */ -#define TARGET_MAP_STACK 0x20000 /* ignored */ -#define TARGET_MAP_HUGETLB 0x40000 /* create a huge page mapping */ -#define TARGET_MAP_UNINITIALIZED 0x4000000 /* for anonymous mmap, memory could be uninitialized */ -#endif +#include "target_mman.h" #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \ || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \ diff --git a/linux-user/xtensa/target_mman.h b/linux-user/xtensa/target_mman.h index e7ba6070fe..3891bb5e07 100644 --- a/linux-user/xtensa/target_mman.h +++ b/linux-user/xtensa/target_mman.h @@ -1 +1,17 @@ +#ifndef XTENSA_TARGET_MMAN_H +#define XTENSA_TARGET_MMAN_H + +#define TARGET_MAP_NORESERVE 0x0400 +#define TARGET_MAP_ANONYMOUS 0x0800 +#define TARGET_MAP_GROWSDOWN 0x1000 +#define TARGET_MAP_DENYWRITE 0x2000 +#define TARGET_MAP_EXECUTABLE 0x4000 +#define TARGET_MAP_LOCKED 0x8000 +#define TARGET_MAP_POPULATE 0x10000 +#define TARGET_MAP_NONBLOCK 0x20000 +#define TARGET_MAP_STACK 0x40000 +#define TARGET_MAP_HUGETLB 0x80000 + #include "../generic/target_mman.h" + +#endif From patchwork Sun Jul 9 18:28:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700896 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4829208wrs; Sun, 9 Jul 2023 11:39:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlGBcC7yuykaNcdD1tnP1AU0QuxRchu1xLCOx2mOJYUoUpXd8dH6nudLJvy9xUIR0kEroiJT X-Received: by 2002:a0c:dd8c:0:b0:62b:33fb:d04c with SMTP id v12-20020a0cdd8c000000b0062b33fbd04cmr9496948qvk.31.1688927949904; Sun, 09 Jul 2023 11:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927949; cv=none; d=google.com; s=arc-20160816; b=VWaPm9jotaGsxoexix+nAOv+jpBYxfG6H2JaC+Vx2C1BNcem8fl5u9TZr9QnRvwXfW iPtmoCOLJBW+gatzZEYt6Ytsa5YfKliJOyWW+25wZKorhi+8DX2mjfZ2bId24GajTJGq 0usUmJb2B0pAczq1oVYM4CGUB3rVbM2p768KQkIL/Y/61O+sKjZ36d1TE45TIveB3Q+N O8g3QmNC+O30+A/FIezyNalPyudiq4Q5zpFxOI4aQcALjHJuxol6+7+Qmtm1Ge7JLJ/P kVu96ccxaWKebwIfm5EPqhZYRbvspJpJy8pJdKZPPA9ATbzawYUh+iMKY9BCl1I5Qdi+ ZvgA== 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:cc:to :from:dkim-signature; bh=7XT7/zvTpZMeqxSdbndcDLpIQTRXhkVJ5EOXRYsTIYQ=; fh=J9/n186FVRrl/nfQIqc4qEum8K7z3A9aFNkBgET3s3A=; b=n1xCfBq7N0X/jviO6Blm9OUjmLp4otmnrDWNUbOwGFP0b+E5ws92zWNBFyYrkVwLNv NYdG0bpaPmy1qGws5wKJQnHtGKdEpwYjTulZ/hXULmThF8mkBEBBXg/NJlXEE6LsIGK2 hoJxcpwwESuEeFTKTnVAh9NonVo6ZTkvfxG4UeXJ9ypXZfmjUK90ATeylSKrgGPhp6X0 hedhzpAqdOyZAVYimoesLz/+JKJwkNGivB7YwhDJheY1HIy9Mqz0vEDcPU+ZnF83vxbf VFtPNvlFIHOwQmxN9pbEhpWi3JaGMUTU5TPhYdP9+biiTIZyl326fVJZMwg3gNUfWYBH fYOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y3jTRAGh; 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 h21-20020a0cab15000000b006367dfd12e1si4861505qvb.123.2023.07.09.11.39.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:39:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y3jTRAGh; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZEP-0005sa-NL; Sun, 09 Jul 2023 14:34:01 -0400 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 1qIZDm-0003IU-MB for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:22 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZDk-0004Ap-Qc for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:22 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3143ccb0f75so4500852f8f.0 for ; Sun, 09 Jul 2023 11:33:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927597; x=1691519597; 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=7XT7/zvTpZMeqxSdbndcDLpIQTRXhkVJ5EOXRYsTIYQ=; b=Y3jTRAGhWNlLnjxFvFMZObU7LDmyk1EIlyWJzFIdgT3RszI4UvO45dVU+4BHS2zJmy yFG6Xu4v2b3JXPdYsIvG8+5tT0g5dC744DDnbo9uBz5q5B1nV2xacBL7AKODFSNTu86c p4Zq7Vud8zWagOUY4h3fPSTFSsb/Awh29YXWE0YHXXyN9MufQ64j0bPmAjWQYVtdfgLp u2Pi+uvU1t4inDzcebn8g6QXH2YNXi/NgarIX3p/HaXzThT1d00cyAw9SQo0DGABWGGa lI6F+EscYc91tqODeDQfz02g/jPt/LVEbQ0q0LOrh4OwO7QAgn+hV4d2z7uTvoQGbfGY wSzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927597; x=1691519597; 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=7XT7/zvTpZMeqxSdbndcDLpIQTRXhkVJ5EOXRYsTIYQ=; b=U2tIt4WpGhwuAuWn7sKRIEMvAwgBPo0k3qOwY/jDPgWCt56YtL0uyXuTJD1TxtpYa9 3YBCf/+/9G+Wbx3Z9jceyJZm4bpoh2KIw6/jwVbDzIQhEaV3RHzOKk1oc16ELqPSIjPb nyiwt9JKc6pLFj764CXYcjDW6wnmLYfszcUBacLl7qlBjSj9vQwsfsc0YEOU7iFtq+zf u7+uip2qTNDYMqogQHhKpDu8Tgsfqg6CAOhZCD/irXSWL8eK7+chmHfytxVnHzBnXC/m o6gfbIh9B+Y9nCkdKekTj9sxBHCZT/1wVtUj7tQEs1Jgl6/cRO/HzDY6muDiNvxsAKn1 iWGg== X-Gm-Message-State: ABy/qLaflYDH9GsL7bny2tTFf7OXSCW+i3yjCQTuJdsH1zODQqmg2a2I X8m3mKJlv+PhvSkr9+gUTf6XxknsSeW4SW0H/EcrlA== X-Received: by 2002:adf:ee8c:0:b0:314:748:d59d with SMTP id b12-20020adfee8c000000b003140748d59dmr11590079wro.27.1688927597527; Sun, 09 Jul 2023 11:33:17 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 24/45] linux-user: Split TARGET_PROT_* out of syscall_defs.h Date: Sun, 9 Jul 2023 19:28:59 +0100 Message-Id: <20230709182934.309468-48-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x434.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Move the values into the per-target target_mman.h headers Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20230707204054.8792-8-richard.henderson@linaro.org> --- linux-user/aarch64/target_mman.h | 8 ++++++++ linux-user/generic/target_mman.h | 6 +++++- linux-user/mips/target_mman.h | 2 ++ linux-user/syscall_defs.h | 11 ----------- linux-user/xtensa/target_mman.h | 2 ++ 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/linux-user/aarch64/target_mman.h b/linux-user/aarch64/target_mman.h index e7ba6070fe..f721295fe1 100644 --- a/linux-user/aarch64/target_mman.h +++ b/linux-user/aarch64/target_mman.h @@ -1 +1,9 @@ +#ifndef AARCH64_TARGET_MMAN_H +#define AARCH64_TARGET_MMAN_H + +#define TARGET_PROT_BTI 0x10 +#define TARGET_PROT_MTE 0x20 + #include "../generic/target_mman.h" + +#endif diff --git a/linux-user/generic/target_mman.h b/linux-user/generic/target_mman.h index 7b888fb7f8..ec76a91b46 100644 --- a/linux-user/generic/target_mman.h +++ b/linux-user/generic/target_mman.h @@ -23,7 +23,11 @@ #define TARGET_MAP_NORESERVE 0x4000 #endif -/* Other MAP flags are defined in asm-generic/mman-common.h */ +/* Defined in asm-generic/mman-common.h */ +#ifndef TARGET_PROT_SEM +#define TARGET_PROT_SEM 0x08 +#endif + #ifndef TARGET_MAP_TYPE #define TARGET_MAP_TYPE 0x0f #endif diff --git a/linux-user/mips/target_mman.h b/linux-user/mips/target_mman.h index cd566c24b6..e97694aa4e 100644 --- a/linux-user/mips/target_mman.h +++ b/linux-user/mips/target_mman.h @@ -1,6 +1,8 @@ #ifndef MIPS_TARGET_MMAN_H #define MIPS_TARGET_MMAN_H +#define TARGET_PROT_SEM 0x10 + #define TARGET_MAP_NORESERVE 0x0400 #define TARGET_MAP_ANONYMOUS 0x0800 #define TARGET_MAP_GROWSDOWN 0x1000 diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 041105b7a7..77ba343c85 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1227,17 +1227,6 @@ struct target_winsize { #include "termbits.h" -#if defined(TARGET_MIPS) || defined(TARGET_XTENSA) -#define TARGET_PROT_SEM 0x10 -#else -#define TARGET_PROT_SEM 0x08 -#endif - -#ifdef TARGET_AARCH64 -#define TARGET_PROT_BTI 0x10 -#define TARGET_PROT_MTE 0x20 -#endif - #include "target_mman.h" #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \ diff --git a/linux-user/xtensa/target_mman.h b/linux-user/xtensa/target_mman.h index 3891bb5e07..3933771b5b 100644 --- a/linux-user/xtensa/target_mman.h +++ b/linux-user/xtensa/target_mman.h @@ -1,6 +1,8 @@ #ifndef XTENSA_TARGET_MMAN_H #define XTENSA_TARGET_MMAN_H +#define TARGET_PROT_SEM 0x10 + #define TARGET_MAP_NORESERVE 0x0400 #define TARGET_MAP_ANONYMOUS 0x0800 #define TARGET_MAP_GROWSDOWN 0x1000 From patchwork Sun Jul 9 18:29:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700898 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4829261wrs; Sun, 9 Jul 2023 11:39:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlEBkqGVGp0mKNmdTjRkdOVjUzJP4bPdIZKjoJHgyGtPfzIVyYwU5iTJDImFMXJo+N+XYNLq X-Received: by 2002:a0c:b55a:0:b0:639:91be:2f1a with SMTP id w26-20020a0cb55a000000b0063991be2f1amr5248488qvd.60.1688927960962; Sun, 09 Jul 2023 11:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927960; cv=none; d=google.com; s=arc-20160816; b=XF2eP3ljSOkAwZf3iz41InNkuDAcQE3DcYtiRsNrHgqMdBf+5G5Rn5a1CdEk+pfK9O rzc1KfiyYJ5vURZUCyRxclfU9jlA3S5UNR0EopzBugGaDboeh0jQok5Hu1tPD/vLNF79 Kql/MCFnDMYgAuatxOZowDdXQs1CKTknLaB5OQgFHuwT/8F89n/oigEIp1MTRJz3hlTu Xdte34/gisrH0eaMOrlCmUir2HJTqHJ2FT3zih4Jw+rFAkBd3nlEcexl3GYJ1fmdH/9I aQE/LWISRZtgNGsYsxoaDO1ze6jU2EICKqL5XqKtwJnFcV5s1cQaomKLj8KJuKn9xKMJ 65vg== 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:cc:to :from:dkim-signature; bh=WbTpqwootsmsPZFIj0kNAknK91pBd8Tm6VoiJxSZmAw=; fh=3IEiF/YPZ00TE94rna3Orj/L+TRFhpuNf7ElRJz3ubE=; b=jHUec7Z5OuUPuPAVT9OyASbbBg0MSbSJUsZ7mCctnz1HpZTMxcLYwjcQU7zd7FQaEx vaLkIiQ+4BMBOrG8xV4BBkwqtbF6nb2UMCI8hj7ZtLT3CTV4SSpPGcljTplJ9KsPs5P1 VPdJ/vR3rPwB0/See1RLK9T6u5o7DhaENfDREJ7m0ap6crI0mqYt2W9vlqbUthUpRS0Z b3HhhVgzU/ck55N365+Ipua4xcllqZ1FZYiMzc1kwWZHLdbKTT95Tj9y0AMwCKXcY7pN pGMbJEsuwLVbIjbeYCq+o/T/hp7QjdMXRWH9Kw+DY0arrEKlyTG1THij5CaAmkTsISm2 H6AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uRmNxWE5; 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 x11-20020a0cb20b000000b006260b52a5c4si4752480qvd.389.2023.07.09.11.39.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:39:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uRmNxWE5; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZE8-000414-1w; Sun, 09 Jul 2023 14:33:44 -0400 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 1qIZDp-0003Re-3Y for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:26 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZDl-0004BC-7V for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:23 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fb4146e8ceso39594475e9.0 for ; Sun, 09 Jul 2023 11:33:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927600; x=1691519600; 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=WbTpqwootsmsPZFIj0kNAknK91pBd8Tm6VoiJxSZmAw=; b=uRmNxWE5KF3dlnd0e7ZJqXCjPdhZbigBAxIDblgtYWMmQnDU5nH6XxMSkKrNPDHcB2 c+wFvqUmQUntB2zatQquQJAMW2NCiGR20OtgyHJbwEVf4+AkmoEAij8rZEpQl+emtxjh lDNkzWKUuLv+vwtYc1E60NZtv6j5Dfw0Ik7AwxjqBAQjbRWug3hrFzBXYbtVh5h3ck+l +WP+bM4lgt3e4IeLH4twRmwIP+8tap1Mk7IFbyXoun00oF0HW8CaTsC7w1m8qZ8KZQcL CSj9cYoAOCFWOghc6jLoMLaoW5m3WRUuawu1XK9V8xlAytz+sLe8lqkmEA0SkR8/hOHk NYYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927600; x=1691519600; 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=WbTpqwootsmsPZFIj0kNAknK91pBd8Tm6VoiJxSZmAw=; b=LL3NIaqKZe6jrjAABe3srzf11QaXWvZ5h66f4wCkCcy7jiXD3lh47PwA2tb8zhh7aH IIfx9DVWvGOm7MjTMQ0MiIJxfmMPHDFr7pEYrg3TB2LKH5Dsvt2dw4IoA5HwIVk299Kg fJX69OfoK9Kgdid6E/k0p0GMqQc7b7LBZtQ8QpwxlQ/hWjh+84oO/+oYbz1zTOVk7p7T PM6R+1+4w9aiqJQEEQJoFf90lw9xzSpHY66GtnDmg210QIMCnFp/TRGyeq//kMxg26mX ql3wGG6sxN8BnMsTVMrb9E3JZ5vKo3xlN0gkxbP68SNR5I86AJF6axth3LFNDF9EuyJK ui7A== X-Gm-Message-State: ABy/qLZDjgleYndqociWurbKl6BbSe/UlHUq/pyGxBueR0sZ+whPAP7F FvXdSoWqXR+/6rIMFYvec4YXNNK3HGUOjs1DOoNx0w== X-Received: by 2002:a05:6000:1b86:b0:314:34dd:aaec with SMTP id r6-20020a0560001b8600b0031434ddaaecmr9476824wru.8.1688927599878; Sun, 09 Jul 2023 11:33:19 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 25/37] target/arm: Use aesenc_SB_SR_AK Date: Sun, 9 Jul 2023 19:29:02 +0100 Message-Id: <20230709182934.309468-51-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x330.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This implements the AESE instruction. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/arm/tcg/crypto_helper.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/target/arm/tcg/crypto_helper.c b/target/arm/tcg/crypto_helper.c index 75882d9ea3..00f3b21507 100644 --- a/target/arm/tcg/crypto_helper.c +++ b/target/arm/tcg/crypto_helper.c @@ -15,6 +15,7 @@ #include "exec/helper-proto.h" #include "tcg/tcg-gvec-desc.h" #include "crypto/aes.h" +#include "crypto/aes-round.h" #include "crypto/sm4.h" #include "vec_internal.h" @@ -45,6 +46,8 @@ static void clear_tail_16(void *vd, uint32_t desc) clear_tail(vd, opr_sz, max_sz); } +static const AESState aes_zero = { }; + static void do_crypto_aese(uint64_t *rd, uint64_t *rn, uint64_t *rm, const uint8_t *sbox, const uint8_t *shift) { @@ -70,7 +73,26 @@ void HELPER(crypto_aese)(void *vd, void *vn, void *vm, uint32_t desc) intptr_t i, opr_sz = simd_oprsz(desc); for (i = 0; i < opr_sz; i += 16) { - do_crypto_aese(vd + i, vn + i, vm + i, AES_sbox, AES_shifts); + AESState *ad = (AESState *)(vd + i); + AESState *st = (AESState *)(vn + i); + AESState *rk = (AESState *)(vm + i); + AESState t; + + /* + * Our uint64_t are in the wrong order for big-endian. + * The Arm AddRoundKey comes first, while the API AddRoundKey + * comes last: perform the xor here, and provide zero to API. + */ + if (HOST_BIG_ENDIAN) { + t.d[0] = st->d[1] ^ rk->d[1]; + t.d[1] = st->d[0] ^ rk->d[0]; + aesenc_SB_SR_AK(&t, &t, &aes_zero, false); + ad->d[0] = t.d[1]; + ad->d[1] = t.d[0]; + } else { + t.v = st->v ^ rk->v; + aesenc_SB_SR_AK(ad, &t, &aes_zero, false); + } } clear_tail(vd, opr_sz, simd_maxsz(desc)); } From patchwork Sun Jul 9 18:29:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700905 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4829730wrs; Sun, 9 Jul 2023 11:41:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlEH+PrJZWQCwj9b8eL+clL6e3akVW5U/IbomOxdqspkmVmpV+yy2NA2fwu8lTFUB+qv1xc+ X-Received: by 2002:a05:620a:178c:b0:75b:23a0:deca with SMTP id ay12-20020a05620a178c00b0075b23a0decamr12676578qkb.72.1688928083889; Sun, 09 Jul 2023 11:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688928083; cv=none; d=google.com; s=arc-20160816; b=nDRAPJq5W+kVAce1aKc0IAlfXnWZXdKXMdTcFzqcjnu72QSb1XU7GUIhqGEp10jXcA CrWJOdtegIbKM3iqRZkvkT0puqYzitpJqUmAXK8ay6Hv4I1hVj4mr6/oDZSRw//983gC Mr44/iN0CSQrTGl1nwSCWIZ2s/ufjHqz+L2bVBd9cZEdwgx2RiQY+0ThqvS+Q4dADWby A4327Mjw+/3YrtylrqL+PM2K2d6DEU0rDV03+IS3supj/uzOn5UzsmqETF45JEnLU1es mEjlFxuoHuy5C6hGG9GRud9dGRP8UReaqE83aMxS4OhQTEGdBtVOg716TiNsSe0/d0Y5 F00g== 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:cc:to :from:dkim-signature; bh=viFchcHGsP+nKMHrpwcA4jNmykwjrSvjDrmv/nDVIvw=; fh=Q/KtKvobZ4aKW4dKNmZSl6eueXWWlvOAYdnlEZxfDJk=; b=oVdJqiBusTcHRFEeI1gE0SWXaElkNNKhQJicnYGGJpdQVVtEyG3bg+o/nxTlvIaWLv gAD+NZDZiGcx+eQCDUBL6NW/6Rv4DXPh0S9TjPjKDyRVVBlusLVkOn/wh8pEPT5DGQue VcRDaHhHUDZZtM3VthWSt1VoCnuhIRlRAgEfJBOslzzZ3/NN3fK3pgl/bje9EjXYqrPu BjmDzDIvAtYpvTz42ZDdfX4RmC0QkDwIrWkvsYnVRdJVzL/wDEDUW4KcTUzun06K5SmA vTwb8FaCenRn6wl3Dw9i396Ca33gdmefHoEDa/I+oUY+CPbsA7PNUeo1k3eVOKZ2tUSe G3rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S16XyXEL; 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 a16-20020a05620a16d000b0074d11ab83e9si4834548qkn.6.2023.07.09.11.41.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:41:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S16XyXEL; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZE9-0004Qn-Cq; Sun, 09 Jul 2023 14:33:45 -0400 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 1qIZDp-0003Rd-24 for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:26 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZDm-0004Cw-Am for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:23 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3142a9ff6d8so4027673f8f.3 for ; Sun, 09 Jul 2023 11:33:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927600; x=1691519600; 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=viFchcHGsP+nKMHrpwcA4jNmykwjrSvjDrmv/nDVIvw=; b=S16XyXELblcr/OMp2WDghERS+Hx24cT4ia1sFMrsT6JejvWOKCMcXU+N9NL5hrHhaB Tv1PW8e91jrnAl01ykA95weOuKrWqLPGvqFngTLJgcJmPQOfq4WXPcAWZXCb2lP26sG1 GFA3TIk6wkGn0afFrAI8v5d+FBrQ2zBySnYSXy+g6t476O7m/LoaNCZUOVnH6U2pS6dD MduoFYovHaAiNkCgWz9x/XlAcDeEIwreED1d98Ezmr0lZhxr0HCPyhMCd06JHhl0tVWa dE4rNZ6I6xKdNMtfgYnx0AiRp4W/UitYyx49I3cLdtRwRYQdyrFXcXhzha0dU590lrm4 3QQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927600; x=1691519600; 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=viFchcHGsP+nKMHrpwcA4jNmykwjrSvjDrmv/nDVIvw=; b=Gx7b75J5dV0uWHwn25l9PUNpoo53vT1NKwgnW+LxpShYKfmY/8eGE5aQUjVbosjvLG qx880HvcdLrjzzw9M4e6zpyOw5Bc8pFjbAX0j/d4NFqc4i+/iYeQuFehzIlSVgO4JRTT jrhDl3f2t3wwZrj4epzqLtwRD0X4MX3wfLIot9Hm+WYKmxu7VrE/o6caZmgIHLSTPyzi wvdHMz9ZBqrFsMlq/PZePDimDqPOfHY/Bs1z8tQ86AL2hBTQbQE6iGr0LER8XHmjFj+F e/mi36wf7H9RapYDqbuPWCZr89Gvuzn5l76rB9HlIMxnYPl5Uh9ZIEsTCgnh35hvyCWJ uvYw== X-Gm-Message-State: ABy/qLY/go4IBoowhc7khkaG+VnJFXXVLz0sSjnVlJgQPZIRx+d3bpTV vC5xM0N0+owe9DjI/MA0Km3nwfay8G6V9oY0sC9hgg== X-Received: by 2002:a5d:6601:0:b0:314:10c1:881d with SMTP id n1-20020a5d6601000000b0031410c1881dmr9949103wru.68.1688927600623; Sun, 09 Jul 2023 11:33:20 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH 26/45] accel/tcg: Introduce page_check_range_empty Date: Sun, 9 Jul 2023 19:29:03 +0100 Message-Id: <20230709182934.309468-52-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x430.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Examine the interval tree to validate that a region has no existing mappings. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20230707204054.8792-10-richard.henderson@linaro.org> --- include/exec/cpu-all.h | 12 ++++++++++++ accel/tcg/user-exec.c | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 472fe9ad9c..94f828b109 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -224,6 +224,18 @@ void page_set_flags(target_ulong start, target_ulong last, int flags); void page_reset_target_data(target_ulong start, target_ulong last); int page_check_range(target_ulong start, target_ulong len, int flags); +/** + * page_check_range_empty: + * @start: first byte of range + * @last: last byte of range + * Context: holding mmap lock + * + * Return true if the entire range [@start, @last] is unmapped. + * The memory lock must be held so that the caller will can ensure + * the result stays true until a new mapping can be installed. + */ +bool page_check_range_empty(target_ulong start, target_ulong last); + /** * page_get_target_data(address) * @address: guest virtual address diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index d95b875a6a..ab684a3ea2 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -598,6 +598,13 @@ int page_check_range(target_ulong start, target_ulong len, int flags) return ret; } +bool page_check_range_empty(target_ulong start, target_ulong last) +{ + assert(last >= start); + assert_memory_lock(); + return pageflags_find(start, last) == NULL; +} + void page_protect(tb_page_addr_t address) { PageFlagsNode *p; From patchwork Sun Jul 9 18:29:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700901 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4829358wrs; Sun, 9 Jul 2023 11:39:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlHeRSOL4B4FHzQ81MJql9Eq9JVG9AAbOEraeVhzsio8Ex2C4GA2aKVZH4XnWhqnHyr5FSRf X-Received: by 2002:a05:620a:4141:b0:766:f9a5:c7ec with SMTP id k1-20020a05620a414100b00766f9a5c7ecmr12652782qko.18.1688927984606; Sun, 09 Jul 2023 11:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927984; cv=none; d=google.com; s=arc-20160816; b=lLJzf/FY6P/V+ZZQKbFq1fkU/hzz9LHifrjyIf9psLoAdTtC/TdRCU4zc81faeus9C P1qPHfl+JoHPVG0gB7UqrFoUt/+JJAsYGGIxHRy986hrI39autolmmUcMV4ZdU9Fk0Z5 6kHi9PPTP/rjbRQAYRAu6NEGAyFbNFshZ47JtUkt+S9ohRtSi/S0wGFCPlSMTRI5VSKZ vEGsRWe9kw4BSgZXTPcRDTbBZOZkvdAJjV0ZJYMLhXJzyF/rfkji8hixHsajfxX/oUC5 DqBLXZjXld6unEGdP03vWJkAMq/y+79ZD+pvNxA+b+PeP7cd7OWO3BnXyGFuI40ekS+Y slog== 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:cc:to :from:dkim-signature; bh=ZraICE1rSSuyJwFU+r8vOCOFS1v3NI7u5DpDqpVSLj4=; fh=TaZCENeteU7KJWs7MRbYIL1hiC/3Q7pMtkyczfsO15k=; b=j8zvvE5dKHEUURDX3YyZ5nFFn8Hz+iXK5ASkDd6XMt8XT6mRsYNUBi7WJrfXwa7Wwp o37mmME86N+helaNzLAtg1A/DKfg0olPFAR3TovEN5NTsp4RVZJBSg8s8zvHXVISNn+K sTx3Fy8ZNw3nPlKCD5+iX9jqX0Kk1qVAmWT7FCk5HeQJzYTCVoqCG0Pg3GPD9YyFq2+M ce5hRwR3Xh/JqfkVVnF/2XE8LRmGskKluWTbeYDxIYG/fT2t3QHhnKXAn00TUZidO8Xg VY+CFXC1PsWTxvf92He8PkyXRxqw7OHIGO65k+et3Y/rhQFvTC98p0LJGwJ/Hcy3cmfK kDmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RpCPrxDP; 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 bj38-20020a05620a192600b00767d4aad122si244682qkb.301.2023.07.09.11.39.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:39:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RpCPrxDP; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZEF-0005Nl-Hx; Sun, 09 Jul 2023 14:33:51 -0400 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 1qIZDp-0003Ru-8j for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:26 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZDn-0004DR-L8 for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:24 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3fbc6ab5ff5so39279625e9.1 for ; Sun, 09 Jul 2023 11:33:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927602; x=1691519602; 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=ZraICE1rSSuyJwFU+r8vOCOFS1v3NI7u5DpDqpVSLj4=; b=RpCPrxDPWDuIDYJcsr0IynwmWGxTCXXvAqP6bOQs6IcfErSvvPixiPsTgTKDOrycm7 huQCrrfYVoqZv/P8R9DqjTPMFkdf/OUj6NCAMXbZ3JMlI8hSsFuzLpr36fWIAU2cX1XG OoIQ6UN5KAK44oqFQpqE1Ma4SoMDJcD/mylZ1XjxNSkR5MSkbHRLSMkSfdeha4lggbVM bCwm8rMtgsR6+WdwqGqLkyutawiwn7YmH2IgXeaZQA3FmqZRm6tGLWMjnQ+wZF+VFmRb HXlIqvWMC+e5K4BWyW0ltwbU9yjVmoXYp3PKNsYdtYbYo8WHO26zj5Hip5MOCZnN18sG dBtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927602; x=1691519602; 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=ZraICE1rSSuyJwFU+r8vOCOFS1v3NI7u5DpDqpVSLj4=; b=FFO9E/NYd1M5q9Da2RCVeNwweYasbKMlBdpiYHTp9ELmllIEncCS3jBGBDXA9rd7M0 0OG4FtgwSyfDtLIykdbSl/z4w56HuTsEB+Ycq4vgZ++1Mz3j/UgsgO6eqPtAw9rv05Oj QhM1/gM4rsMKHTLq0/ffmhQDmG3j8tyVwu0Wgv5DR10/uc8QI7G+apxVAPbMt7At18KJ +p9L+oZ5g0jtIZOi7zm85yS0e6nUYJx451wclNpYvo9UkF1dXLD8OVHHwfgiqA3nFMtl 8nuP5U6sBb3dQSBl1r/Jzc7x4lPRURoziPBSSXvBSIRi93YeWVWGA/CJ3qItGUsdqbim /yMw== X-Gm-Message-State: ABy/qLZUnknHF72QJdgYL25ndCOHvyVq04HDepuRYXGD/xAirG7Vu7mC sQfk3jgf8VWLfX0ekZv3zC+wiWhupDPtjGGTufGPEQ== X-Received: by 2002:a1c:7318:0:b0:3fb:b61f:c719 with SMTP id d24-20020a1c7318000000b003fbb61fc719mr9062778wmb.33.1688927602411; Sun, 09 Jul 2023 11:33:22 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Warner Losh , Kyle Evans Subject: [PATCH 27/45] bsd-user: Use page_check_range_empty for MAP_EXCL Date: Sun, 9 Jul 2023 19:29:05 +0100 Message-Id: <20230709182934.309468-54-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32a.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The previous check returned -1 when any page within [start, start+len) is unmapped, not when all are unmapped. Cc: Warner Losh Cc: Kyle Evans Signed-off-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230707204054.8792-11-richard.henderson@linaro.org> --- bsd-user/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index 565b9f97ed..07b5b8055e 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -609,7 +609,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, } /* Reject the mapping if any page within the range is mapped */ - if ((flags & MAP_EXCL) && page_check_range(start, len, 0) < 0) { + if ((flags & MAP_EXCL) && !page_check_range_empty(start, end - 1)) { errno = EINVAL; goto fail; } From patchwork Sun Jul 9 18:29:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700895 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4829151wrs; Sun, 9 Jul 2023 11:38:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlEFV1EgKi1BrVShKaIgzmeRhPYutXgTl9iaPPrUUmKTIPUpGdx67x49jMQXCDPXHOQbcgei X-Received: by 2002:a0c:e004:0:b0:622:199c:c4dc with SMTP id j4-20020a0ce004000000b00622199cc4dcmr9745258qvk.51.1688927937733; Sun, 09 Jul 2023 11:38:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927937; cv=none; d=google.com; s=arc-20160816; b=Feu+7+G4f/2uqSiWaoYR6upZveonOyvPlWlTCNkKasrDpd2xmGMczuOko0n/A7rHAA UlqOZGIqsPxShlL+lJWjwTloio+cKiLlw8OTB8vDBeLmmB054TrAhSnasZ2tF0NhMOvC D0Rk6pBkiiJNhxnhlRG1UNUWXeMiUPG7mThOBQ6QQWPXJ6tqa5/NfQsH2mB3lC7zivdA GHX6ZXCGOqiDEmwPuX3NKy6QxjY3BCP2lypZ9eutcGmWYEQFj/AY/TQhsXu+CD6wH0fF baN3igmL04VLUgOsfB89KVjiuzyTNFA62bj+YZnlVkJlK46V8TwyABegLl05YN3ROV4d Rveg== 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:cc:to :from:dkim-signature; bh=ZNJt+xQSaKcqRS2slBC4RsFLFu+ocScsUgiRpjPIdes=; fh=3IEiF/YPZ00TE94rna3Orj/L+TRFhpuNf7ElRJz3ubE=; b=YszFiKbEkAKqEq0B4EhBnetXkN91jXUmnVJAYpnNr6ZvDKM97m1fGX8TEMJyFJd7aV oPb7UUpJEgCJozjem55zc2QKoHKX2PkAh66uiuWuqvrg/t6nf6fanyigBanEUjucJdVr eCTB1eifvpfwRFZkYslvciG+fub8H3k+RXeaqp3GDsklUbicvaBXzD+z4imIfYCaE6cC 2tS2uSTPgXecl9318FauU+vrk7nFXiITEvzKpV3psYhbpxDy0kKMFuay0ZoUAXlCAqnH O3gNM4hz0GwnW4AVFz45kf10F3h7ltKSa67J1Ahq+Hcv3ppP/WeQ2TXUk0sEXX6JMAWT judQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FxZvPlWT; 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 d15-20020a0ce44f000000b006376e60c92csi4836965qvm.159.2023.07.09.11.38.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:38:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FxZvPlWT; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZEA-0004b7-HC; Sun, 09 Jul 2023 14:33:46 -0400 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 1qIZDu-0003Wo-D7 for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:33 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZDq-0004El-9j for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:29 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fbef8ad9bbso42002125e9.0 for ; Sun, 09 Jul 2023 11:33:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927605; x=1691519605; 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=ZNJt+xQSaKcqRS2slBC4RsFLFu+ocScsUgiRpjPIdes=; b=FxZvPlWTr/jm9Mpm7/6AppNvIqAR9ZwESYc68AEZ4IzHMTdTkKlrkRKx9Bhwg+qUqt d1cUP4dJTd9+164djJcx3bJSNge8d+E/5HBrhYcw+uYbZKjXeGQh49a0kPJtatqfuTIt avnHEL+PNR1dGPvxjUCBvLGphfGqZe/hn0Mi9xrAR6u/ID2//p1wpUdwBxNkYr5UmZoB 8QJcG3OadYA0jaG7z+iobNsW84KEYHm8wDlVS6a/f25EBsWlUMeG+C2R0m4b5LxRLYM6 suqyRop0yIiHPb8WHwC1OV1HIW4fMX7UTl/Lg7eF8qQwuGB7Z8P/ovNuEBlA950BcDNJ mixQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927605; x=1691519605; 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=ZNJt+xQSaKcqRS2slBC4RsFLFu+ocScsUgiRpjPIdes=; b=CN8vrMQsJFt86XrpX9LR2hDiNocdAa0c4mF7Yp37W/id8QsSDnvDWbhOoQXH0/CKI4 jfqzzemwfOFlJfedrkwxlLqaceQsY80JbiozRMkxZtNGNibMti6WFYJC5dSlpZeh6Ynm iR+KzLpxqxbCcKZX3wjtJkEGJcaQwEJFan/Cg6anaqbJpfgOTOMaM+UBU256594uv+iI hVQnSJ2PSmFYTlmiNMKZqN8P110nwocuCNP68LV20Vpo2H+wajJweRr54XWDIcQBE5E2 pQa27udHLC8e2yCOfjxuHf4LelXGIOVX6oHaM8OwxMO/b0t39tsMpzxu915vIFaG7mRv 9mHg== X-Gm-Message-State: ABy/qLYHeDQHwR2De9mMIv3UGAmE4AUlGGMqtLTEWYaHo0J+biuD0kc8 14eXfQLI3r0e1C7NsQdjP1m3gJh38UzTMlvhkhuCKA== X-Received: by 2002:a05:600c:294a:b0:3fc:1a9:7900 with SMTP id n10-20020a05600c294a00b003fc01a97900mr3217935wmd.16.1688927604868; Sun, 09 Jul 2023 11:33:24 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 28/37] target/arm: Use aesdec_IMC Date: Sun, 9 Jul 2023 19:29:08 +0100 Message-Id: <20230709182934.309468-57-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32f.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This implements the AESIMC instruction. We have converted everything to crypto/aes-round.h; crypto/aes.h is no longer needed. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/arm/tcg/crypto_helper.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/target/arm/tcg/crypto_helper.c b/target/arm/tcg/crypto_helper.c index 1952aaac58..fdd70abbfd 100644 --- a/target/arm/tcg/crypto_helper.c +++ b/target/arm/tcg/crypto_helper.c @@ -14,7 +14,6 @@ #include "cpu.h" #include "exec/helper-proto.h" #include "tcg/tcg-gvec-desc.h" -#include "crypto/aes.h" #include "crypto/aes-round.h" #include "crypto/sm4.h" #include "vec_internal.h" @@ -102,23 +101,6 @@ void HELPER(crypto_aesd)(void *vd, void *vn, void *vm, uint32_t desc) clear_tail(vd, opr_sz, simd_maxsz(desc)); } -static void do_crypto_aesmc(uint64_t *rd, uint64_t *rm, const uint32_t *mc) -{ - union CRYPTO_STATE st = { .l = { rm[0], rm[1] } }; - int i; - - for (i = 0; i < 16; i += 4) { - CR_ST_WORD(st, i >> 2) = - mc[CR_ST_BYTE(st, i)] ^ - rol32(mc[CR_ST_BYTE(st, i + 1)], 8) ^ - rol32(mc[CR_ST_BYTE(st, i + 2)], 16) ^ - rol32(mc[CR_ST_BYTE(st, i + 3)], 24); - } - - rd[0] = st.l[0]; - rd[1] = st.l[1]; -} - void HELPER(crypto_aesmc)(void *vd, void *vm, uint32_t desc) { intptr_t i, opr_sz = simd_oprsz(desc); @@ -147,7 +129,20 @@ void HELPER(crypto_aesimc)(void *vd, void *vm, uint32_t desc) intptr_t i, opr_sz = simd_oprsz(desc); for (i = 0; i < opr_sz; i += 16) { - do_crypto_aesmc(vd + i, vm + i, AES_imc_rot); + AESState *ad = (AESState *)(vd + i); + AESState *st = (AESState *)(vm + i); + AESState t; + + /* Our uint64_t are in the wrong order for big-endian. */ + if (HOST_BIG_ENDIAN) { + t.d[0] = st->d[1]; + t.d[1] = st->d[0]; + aesdec_IMC(&t, &t, false); + ad->d[0] = t.d[1]; + ad->d[1] = t.d[0]; + } else { + aesdec_IMC(ad, st, false); + } } clear_tail(vd, opr_sz, simd_maxsz(desc)); } From patchwork Sun Jul 9 18:29:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700915 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4830132wrs; Sun, 9 Jul 2023 11:42:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlGGOhqVaLSXa9ACTvBYZ1WHpVvUwZ19ODyXSzXscXdkjotQe2oUbi3NZ4HoHxydE/fTWnDu X-Received: by 2002:a05:620a:2556:b0:767:6548:dc68 with SMTP id s22-20020a05620a255600b007676548dc68mr11710372qko.20.1688928169494; Sun, 09 Jul 2023 11:42:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688928169; cv=none; d=google.com; s=arc-20160816; b=Fp/bWlsJDv+1zzowCABcKxAhFMFDKsGwGtsEIuVm88Gm/+rJrLsvJmAqt6aiQmJqM0 aeJwrr3q1MGfwHC+761pY9rP08XvQlxU8y+4m4rS4RYA69jCxWPNiBajOdX5HJ/rR2Ns RdTINpcFPDPjpstPmWPI4DGZi9ZOTp3Xa+0YYMwX0sIre58OhUdy6uGO8VZVOD14PV7E 3CISKXGrANBY3OJrk0GWq4HPx5wLtB7kAoKURRWsWZll9O4rdIWv2p4kiEVh1xR6WK/M 2Y2PF5IkVTQySv/j+HmD48quX4VPFnidOwZkS4DXwhQry3uWPKGbRGjPmALFUQ9cga0/ JhqQ== 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:cc:to :from:dkim-signature; bh=7S8fJjWsfM8/RKnCcasDShb0DLhg94fNTjj77rs37DE=; fh=Q/KtKvobZ4aKW4dKNmZSl6eueXWWlvOAYdnlEZxfDJk=; b=otO23LB2f9kM+Wjn3aO2ZKOvN8bqhRvQjDLq0QCGU5txiXLUtnKfstEW8+oTBdXbza mf2+202ZvHW8L1D9uXzBlkvCScpEULgHMOZZhcggRsmXOuQwZdgAviCI3hUK6aIlVRMd fTsWKVAVxWBmVTIy/uyqfGoJ6hy6f2Eo45FbgvsZDCc4a7TzlNQNzQiIQr5MHDgFMJ6B KN/pW3s5XvzCPC4CpeYoLDAzoFhUE0+FiJvD6mLZWEPXAlwpwxi5xPi9cu98qoI8ic66 BgGxB+NuGxfkc9ITPH5w6ZFASrSU+XDKppg4wEdCDN3KjJZfR9Ogto+S3lCVe05iGTVL igag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=thoAjB3G; 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 k1-20020ae9f101000000b007670ed04315si4673765qkg.705.2023.07.09.11.42.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:42:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=thoAjB3G; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZE9-0004PS-97; Sun, 09 Jul 2023 14:33:45 -0400 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 1qIZDx-0003X4-8t for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:33 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZDt-0004F9-6H for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:31 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fb4146e8fcso28087955e9.0 for ; Sun, 09 Jul 2023 11:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927605; x=1691519605; 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=7S8fJjWsfM8/RKnCcasDShb0DLhg94fNTjj77rs37DE=; b=thoAjB3GpxKzMJcx1kcs1fdv/HJfX7A6qoQcNWX16u3f1tAbZANWzjLy0zZYzfdPWl 4q6roZnfopurtCdH/6cETa9Hq4wtedV8RlP4KV9D2A1Th1D35hTOe4ju9iyRMR1FFOzB uu+/fCVoLwkZZM4MBauvIDCGNL2EJZZtOYOz9nDfXUn7sMHR/6Bpdxk/JoicIwdGFP/1 j4tOUSsKyI1pSVFrDFGuMTOlxBZoeJVilSkwowpI/JKInmuLNq/ajmGKbRQyJt1J0RIT rfvsVFWKHthiUEoSy3aisPuKSSzO1kfsE+gbwaYT8ag2CutdV5U4AWoYTirdbgfC5luF CQGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927605; x=1691519605; 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=7S8fJjWsfM8/RKnCcasDShb0DLhg94fNTjj77rs37DE=; b=QyzfaF6M2yrBfwu66jTUvn3B8Bo4dPfW1os0cry5K1yNUBv+e1PHjT2HdDnO8Ol4Jl PUMROlUScFkwhNmtXdWuEe8PHDobGN0XLO50bsGWxbMnC2IY9CB5livzBDznje2tLzYe Yp7YadRkGOaYh7HYcC9dHsNOicOsXyulFKCPekKm4FQDI39ZnuTwkRCc0L1slxLZxGQz mHPW6p/E9c2DsZ1CreDXksCivQhUJIo1WEIkHtxO+WxhWrbZW1L2lmUZUBTf0ozGxWsG rdMs6fMX4X0865dwgbo6zdiYRgWstAlXE1QV4Hukx4jPTwsA/9dfT+QB1mefxHwVjTNB XrwA== X-Gm-Message-State: ABy/qLbLN9Q3i9Gd9x2k22IsTIFtZ1vukRxACR9/nmQBtugKu1nWg/Dw rWBStSOqmrKZTFcFdX+9GX90ouhCJfWIY/pVUYur+A== X-Received: by 2002:a1c:741a:0:b0:3fc:1a6:79a9 with SMTP id p26-20020a1c741a000000b003fc01a679a9mr1230997wmc.16.1688927605638; Sun, 09 Jul 2023 11:33:25 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH 29/45] linux-user: Split out target_to_host_prot Date: Sun, 9 Jul 2023 19:29:09 +0100 Message-Id: <20230709182934.309468-58-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x330.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Split out from validate_prot_to_pageflags, as there is not one single host_prot for the entire range. We need to adjust prot for every host page that overlaps multiple guest pages. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20230707204054.8792-13-richard.henderson@linaro.org> --- linux-user/mmap.c | 78 ++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 9dc34fc29d..12b1308a83 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -69,24 +69,11 @@ void mmap_fork_end(int child) * Return 0 if the target prot bitmask is invalid, otherwise * the internal qemu page_flags (which will include PAGE_VALID). */ -static int validate_prot_to_pageflags(int *host_prot, int prot) +static int validate_prot_to_pageflags(int prot) { int valid = PROT_READ | PROT_WRITE | PROT_EXEC | TARGET_PROT_SEM; int page_flags = (prot & PAGE_BITS) | PAGE_VALID; - /* - * For the host, we need not pass anything except read/write/exec. - * While PROT_SEM is allowed by all hosts, it is also ignored, so - * don't bother transforming guest bit to host bit. Any other - * target-specific prot bits will not be understood by the host - * and will need to be encoded into page_flags for qemu emulation. - * - * Pages that are executable by the guest will never be executed - * by the host, but the host will need to be able to read them. - */ - *host_prot = (prot & (PROT_READ | PROT_WRITE)) - | (prot & PROT_EXEC ? PROT_READ : 0); - #ifdef TARGET_AARCH64 { ARMCPU *cpu = ARM_CPU(thread_cpu); @@ -114,18 +101,34 @@ static int validate_prot_to_pageflags(int *host_prot, int prot) return prot & ~valid ? 0 : page_flags; } +/* + * For the host, we need not pass anything except read/write/exec. + * While PROT_SEM is allowed by all hosts, it is also ignored, so + * don't bother transforming guest bit to host bit. Any other + * target-specific prot bits will not be understood by the host + * and will need to be encoded into page_flags for qemu emulation. + * + * Pages that are executable by the guest will never be executed + * by the host, but the host will need to be able to read them. + */ +static int target_to_host_prot(int prot) +{ + return (prot & (PROT_READ | PROT_WRITE)) | + (prot & PROT_EXEC ? PROT_READ : 0); +} + /* NOTE: all the constants are the HOST ones, but addresses are target. */ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) { abi_ulong end, host_start, host_end, addr; - int prot1, ret, page_flags, host_prot; + int prot1, ret, page_flags; trace_target_mprotect(start, len, target_prot); if ((start & ~TARGET_PAGE_MASK) != 0) { return -TARGET_EINVAL; } - page_flags = validate_prot_to_pageflags(&host_prot, target_prot); + page_flags = validate_prot_to_pageflags(target_prot); if (!page_flags) { return -TARGET_EINVAL; } @@ -143,7 +146,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) host_end = HOST_PAGE_ALIGN(end); if (start > host_start) { /* handle host page containing start */ - prot1 = host_prot; + prot1 = target_prot; for (addr = host_start; addr < start; addr += TARGET_PAGE_SIZE) { prot1 |= page_get_flags(addr); } @@ -154,19 +157,19 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) end = host_end; } ret = mprotect(g2h_untagged(host_start), qemu_host_page_size, - prot1 & PAGE_BITS); + target_to_host_prot(prot1)); if (ret != 0) { goto error; } host_start += qemu_host_page_size; } if (end < host_end) { - prot1 = host_prot; + prot1 = target_prot; for (addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) { prot1 |= page_get_flags(addr); } ret = mprotect(g2h_untagged(host_end - qemu_host_page_size), - qemu_host_page_size, prot1 & PAGE_BITS); + qemu_host_page_size, target_to_host_prot(prot1)); if (ret != 0) { goto error; } @@ -175,8 +178,8 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) /* handle the pages in the middle */ if (host_start < host_end) { - ret = mprotect(g2h_untagged(host_start), - host_end - host_start, host_prot); + ret = mprotect(g2h_untagged(host_start), host_end - host_start, + target_to_host_prot(target_prot)); if (ret != 0) { goto error; } @@ -212,7 +215,8 @@ static int mmap_frag(abi_ulong real_start, if (prot1 == 0) { /* no page was there, so we allocate one */ - void *p = mmap(host_start, qemu_host_page_size, prot, + void *p = mmap(host_start, qemu_host_page_size, + target_to_host_prot(prot), flags | MAP_ANONYMOUS, -1, 0); if (p == MAP_FAILED) { return -1; @@ -233,7 +237,8 @@ static int mmap_frag(abi_ulong real_start, /* adjust protection to be able to read */ if (!(prot1 & PROT_WRITE)) { - mprotect(host_start, qemu_host_page_size, prot1 | PROT_WRITE); + mprotect(host_start, qemu_host_page_size, + target_to_host_prot(prot1) | PROT_WRITE); } /* read the corresponding file data */ @@ -243,11 +248,13 @@ static int mmap_frag(abi_ulong real_start, /* put final protection */ if (prot_new != (prot1 | PROT_WRITE)) { - mprotect(host_start, qemu_host_page_size, prot_new); + mprotect(host_start, qemu_host_page_size, + target_to_host_prot(prot_new)); } } else { if (prot_new != prot1) { - mprotect(host_start, qemu_host_page_size, prot_new); + mprotect(host_start, qemu_host_page_size, + target_to_host_prot(prot_new)); } if (prot_new & PROT_WRITE) { memset(g2h_untagged(start), 0, end - start); @@ -460,7 +467,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, { abi_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len, passthrough_start = -1, passthrough_end = -1; - int page_flags, host_prot; + int page_flags; mmap_lock(); trace_target_mmap(start, len, target_prot, flags, fd, offset); @@ -470,7 +477,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, goto fail; } - page_flags = validate_prot_to_pageflags(&host_prot, target_prot); + page_flags = validate_prot_to_pageflags(target_prot); if (!page_flags) { errno = EINVAL; goto fail; @@ -553,10 +560,12 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { unsigned long host_start; + int host_prot; void *p; host_len = len + offset - host_offset; host_len = HOST_PAGE_ALIGN(host_len); + host_prot = target_to_host_prot(target_prot); /* * Note: we prefer to control the mapping address. It is @@ -617,7 +626,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, * msync() won't work here, so we return an error if write is * possible while it is a shared mapping */ - if ((flags & MAP_TYPE) == MAP_SHARED && (host_prot & PROT_WRITE)) { + if ((flags & MAP_TYPE) == MAP_SHARED + && (target_prot & PROT_WRITE)) { errno = EINVAL; goto fail; } @@ -631,7 +641,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, if (pread(fd, g2h_untagged(start), len, offset) == -1) { goto fail; } - if (!(host_prot & PROT_WRITE)) { + if (!(target_prot & PROT_WRITE)) { ret = target_mprotect(start, len, target_prot); assert(ret == 0); } @@ -643,14 +653,14 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, if (real_end == real_start + qemu_host_page_size) { /* one single host page */ ret = mmap_frag(real_start, start, end, - host_prot, flags, fd, offset); + target_prot, flags, fd, offset); if (ret == -1) { goto fail; } goto the_end1; } ret = mmap_frag(real_start, start, real_start + qemu_host_page_size, - host_prot, flags, fd, offset); + target_prot, flags, fd, offset); if (ret == -1) { goto fail; } @@ -660,7 +670,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, if (end < real_end) { ret = mmap_frag(real_end - qemu_host_page_size, real_end - qemu_host_page_size, end, - host_prot, flags, fd, + target_prot, flags, fd, offset + real_end - qemu_host_page_size - start); if (ret == -1) { goto fail; @@ -678,7 +688,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, offset1 = offset + real_start - start; } p = mmap(g2h_untagged(real_start), real_end - real_start, - host_prot, flags, fd, offset1); + target_to_host_prot(target_prot), flags, fd, offset1); if (p == MAP_FAILED) { goto fail; } From patchwork Sun Jul 9 18:29:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700889 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4828908wrs; Sun, 9 Jul 2023 11:37:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlG1s9YjGxkgUp9x7YeXhpSC9EGCJdrvN1OZjSsp8kkSlF8DhGJwCHxFri6AkKZb+I/eUrCN X-Received: by 2002:a05:620a:2988:b0:767:30a5:4c7d with SMTP id r8-20020a05620a298800b0076730a54c7dmr13517003qkp.24.1688927876196; Sun, 09 Jul 2023 11:37:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927876; cv=none; d=google.com; s=arc-20160816; b=h3nznT7/vjioPfM5/YG7jtecm0puKKfuItxhhUL5+zeyvR4NUTh0tUJpIcFnorq1hw l3MBveIzdlg9m0wldqfHu5Jxi0Dd/BIX/CoJ4f5O3lWse6IAfsTTL0TqaQ3w5Zk5UDpU /ARuEB5PAbuNgrTQ4sKZB8VdpZZ3RTqH25fhR5OEOuzd3emhmKlK9dql4CS9rqDr0a3R 3FM+ZpBdPJxlJp0luDknju4WQCgW0hRLm0BdxJ+Mnu4WwYkQnBrkjPE94pfTyGn7pWGW b14zhhbeVqkByRFnt3N+p2DIeN4qsK6YBmbzfvhOEzxFre0wX77JRR426M2cTPtwIDzy hm7w== 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:cc:to :from:dkim-signature; bh=n45s477h1C3Bg6RmtpzjbWFEleMZVTqSI+26VJaWtyU=; fh=Q/KtKvobZ4aKW4dKNmZSl6eueXWWlvOAYdnlEZxfDJk=; b=i9WepFY9CJ3K2+RCy2e8axnyNk7t0L6hwoaC/yZp/6oOm6dkQ2/kSRTRwSPVXaVYsl eQhmCGFkUhF7XPu8am3bBY4xBf79FhUP59y36CgB4ecLPLb5DGEMinycTdlBd/wxMsDM QfwFShz83DDtoRjKfzjFL91wcIM8BDIgr+UgV62KSZrZ5sGD7pYCHUVV6F4YzPp+N3iA HWi5gIYaPaQboMRW5dppOaZF0w/JXoPHd4SQsCWqhjQu6yKQf0HAQVK2PB/0wKixLLON qgPtdploj3h7MIWG83T1vTTeI8C5i23F9eutcnKhibfsp+fHCwjp9MSL6HI/TbpvsxbF SGuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IB8ycmOv; 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 o3-20020a05620a15c300b0076719299db7si4927641qkm.567.2023.07.09.11.37.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:37:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IB8ycmOv; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZEC-0004tr-K9; Sun, 09 Jul 2023 14:33:48 -0400 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 1qIZDx-0003X2-7g for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:33 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZDu-0004Fd-6A for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:32 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3142860734aso3826039f8f.1 for ; Sun, 09 Jul 2023 11:33:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927607; x=1691519607; 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=n45s477h1C3Bg6RmtpzjbWFEleMZVTqSI+26VJaWtyU=; b=IB8ycmOvK5tx6xi4Wa0QGm8UQPho6UWjQDCIYg7eKygLgYJ3YC0euY63P/uBnYtpJB QCVFWgqIepX5YJqC18ZUGidPJCKJUcdEjJ9uECKL/GuglKrcRVJyZ88nWWD4Cq7eedgV VsGxwkMQN0cO2O5Xu7RoxRwDSeqN6rUk+JbPgBqc9+X7l4LYuQmfv7YkiB7cANaC5sce IOGRX5mIVvJMP26X+dSgFld0ApPpS3LRQhaC9qNAieL7TS0JK17gWPC4w9n+YBj1b5cI 7XbJpFniuvPFWm2WU8whXRKVQ/fFdZTjLsm6MjIXICntW+0T4qn7Hakw0V66iV1NIhQe NF7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927607; x=1691519607; 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=n45s477h1C3Bg6RmtpzjbWFEleMZVTqSI+26VJaWtyU=; b=hJX3ncPFgQpsbcCje2rnNwA8UhHDlTwNOhAJYX9FbwtHhNtJUcrClnxxnDmDSEisl7 f7cQle5xRfLKQcV4IMDeZMgORvTbbK5HAYEJAA3m2m7EWHhZJMemkxfwUshzGXxBmgGs 2eUs2cdhVvysBSVr0dMRyZQSs4w0NLguzu0b3IRytIhZ8GnCuVInKP8zSixF2nZPvBBJ 1tlxviQk62JRNSVYWYSXYLrWk18Rcrs22LoKe/1Uykv/84KOBwOPJ80YCKjMIrgODL+S qFZRuhXe4q5CkXtARJ7B8CNrSpDqwVhAxUan1lBl2Yo0itrNeaQsbO9ZYao7VPOo5Lom Yfvg== X-Gm-Message-State: ABy/qLYNeXfjudOZu2+xIjGxlQWOvqzb195LG0CRES1OFCn0USW21pzj yeE25A5y6tyO8nUB8AVRwzQWspdqvJfNcD/09Gbp0Q== X-Received: by 2002:a5d:4b91:0:b0:315:8f4f:9c50 with SMTP id b17-20020a5d4b91000000b003158f4f9c50mr3667365wrt.16.1688927607326; Sun, 09 Jul 2023 11:33:27 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH 30/45] linux-user: Widen target_mmap offset argument to off_t Date: Sun, 9 Jul 2023 19:29:11 +0100 Message-Id: <20230709182934.309468-60-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42b.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We build with _FILE_OFFSET_BITS=64, so off_t = off64_t = uint64_t. With an extra cast, this fixes emulation of mmap2, which could overflow the computation of the full value of offset. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20230707204054.8792-14-richard.henderson@linaro.org> --- linux-user/user-mmap.h | 2 +- linux-user/mmap.c | 14 ++++++++------ linux-user/syscall.c | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/linux-user/user-mmap.h b/linux-user/user-mmap.h index 480ce1c114..3fc986f92f 100644 --- a/linux-user/user-mmap.h +++ b/linux-user/user-mmap.h @@ -20,7 +20,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int prot); abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, - int flags, int fd, abi_ulong offset); + int flags, int fd, off_t offset); int target_munmap(abi_ulong start, abi_ulong len); abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, abi_ulong new_size, unsigned long flags, diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 12b1308a83..b2c2d85857 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -196,7 +196,7 @@ error: /* map an incomplete host page */ static int mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong end, - int prot, int flags, int fd, abi_ulong offset) + int prot, int flags, int fd, off_t offset) { abi_ulong real_end, addr; void *host_start; @@ -463,11 +463,12 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) /* NOTE: all the constants are the HOST ones */ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, - int flags, int fd, abi_ulong offset) + int flags, int fd, off_t offset) { - abi_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len, + abi_ulong ret, end, real_start, real_end, retaddr, host_len, passthrough_start = -1, passthrough_end = -1; int page_flags; + off_t host_offset; mmap_lock(); trace_target_mmap(start, len, target_prot, flags, fd, offset); @@ -559,7 +560,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, } if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { - unsigned long host_start; + uintptr_t host_start; int host_prot; void *p; @@ -578,7 +579,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, goto fail; } /* update start so that it points to the file position at 'offset' */ - host_start = (unsigned long)p; + host_start = (uintptr_t)p; if (!(flags & MAP_ANONYMOUS)) { p = mmap(g2h_untagged(start), len, host_prot, flags | MAP_FIXED, fd, host_offset); @@ -681,7 +682,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, /* map the middle (easier) */ if (real_start < real_end) { void *p; - unsigned long offset1; + off_t offset1; + if (flags & MAP_ANONYMOUS) { offset1 = 0; } else { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 36c4d88793..8a5a82fcec 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -10436,7 +10436,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, #endif ret = target_mmap(arg1, arg2, arg3, target_to_host_bitmask(arg4, mmap_flags_tbl), - arg5, arg6 << MMAP_SHIFT); + arg5, (off_t)(abi_ulong)arg6 << MMAP_SHIFT); return get_errno(ret); #endif case TARGET_NR_munmap: From patchwork Sun Jul 9 18:29:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700899 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4829286wrs; Sun, 9 Jul 2023 11:39:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlEId7gAgnwfskyvl3rpYrEpJFKqlSDMvzKk3eclgGz8vi4qlr5Rkcz81eWv1VYhIqPZ1oeO X-Received: by 2002:ac8:5851:0:b0:3f6:c0f7:a5d7 with SMTP id h17-20020ac85851000000b003f6c0f7a5d7mr13861424qth.35.1688927965733; Sun, 09 Jul 2023 11:39:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927965; cv=none; d=google.com; s=arc-20160816; b=c+cle+wM47GXGpKisUuUpMKLZImkW7s79DOg/sdJNCf/pshQDtvRyFZM7wNIOLTJAf AwwSxccjwimd7tmG1MmaSoCca1gILnoZHadJx0TDUf78X6TeD7Rs0GwsdtMbRyz9Y881 6OG/hshfVDYWrxop09IUusphVG3vh4b4usKSHVjrnNNpTbufs6nugZNDnNqyE0fSHR7Z stwNJNifjvvYMxpmr0rge9aPUjZKEyovDbt22gQmUK7mhO13b0O/nDOhTzDY83fws73H H/0MXMv/ty8RgYljONoxXb12lm3VLcAsmpzGIEiPpc9WA27p8megNiZrtYOziLGyStjh 9Cfw== 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:cc:to :from:dkim-signature; bh=N9gguT3TBruptKaq1lWfbF+0g4+LhgVIPeZNOW/uhRg=; fh=4nfr0hkxlMpWE4oToQ1q4rzQVecv6te3cGVRc3YFjiI=; b=ePsyMsJBoQqcVgKvEghHZPCIykff1Kv+1O2DJSg+iTe7sm6zuNuF9Eug+W5XJv9BtL 5bWA9hSnG16moL98QsDDNkTKyUr8ie0uGw+HwHRAPI7pCtFcqHqYBwLPS5AlvU9I/goo 3VMXTZZdPgtvIReU/82kQAfqWFhEUT3e2mzjK8JFiJ5fmLJTDYu+itU/aT0ksovKvOSB U901yP0iVgyligbtR0SBVu67X5vChGBfZjpg7+e+8TUCM/s8C9Rfjb62AiOlMuiM5xNq U4Gu7MD/DR3VbjpqFRmQGGD+GEsJTyUrcIUT/ehd4klTcB+L0PL1O97VEOSizrrPcw7j REfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G9K+b0x9; 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 v13-20020a05622a188d00b00403324bd556si4781602qtc.749.2023.07.09.11.39.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:39:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G9K+b0x9; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZEP-0005sX-Ke; Sun, 09 Jul 2023 14:34:01 -0400 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 1qIZDx-0003X1-7X for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:33 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZDu-0004G3-6Q for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:32 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3094910b150so4053614f8f.0 for ; Sun, 09 Jul 2023 11:33:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927608; x=1691519608; 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=N9gguT3TBruptKaq1lWfbF+0g4+LhgVIPeZNOW/uhRg=; b=G9K+b0x9w8fTHKaRB/7mFxdF7zebDiwf/1ae7p57yxhIZMbZ7ru9zNwbLrwKvhysgI I5IFwLo/q39j/pwYp6TvxBedqiiGFDJuRDAgtFrTTrQzliTNOkeVlBMcqrfHdtpf2g72 jApRWKYq48yHz8hWGIX6oFO4rwodJ7U91vR+1igc6Efe0hmBDnJAtDC+6/1NprcjU6lM rchprJEmasgDek4l7hkkuaq8/X9ZwR12PnmIL/CXdKKM5F4tW62MVKgqD0C3Eu/WjEeU dvelBYRFwzB8IIo03P2mlqHnud1vhwlyT1kHGG/3kxpdjncd0Ko2U9lxRIFxq29e9l9n CtsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927608; x=1691519608; 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=N9gguT3TBruptKaq1lWfbF+0g4+LhgVIPeZNOW/uhRg=; b=L9oIsWILnGE6o38WT8DIKPnqn7/2u8sY8Rai8pGPz00Gn+5iaFGBcLSepl30t8Kabo ENH3StzhalF79dDZz1BwuTD0S8LiKz/CHOq9FRWuDNmXwIqHWioH6vjpC9lzkaXEfv21 SskyfoTmpy2sA696cmL4W+xP6n97vZOW1krQ63SVWkKL9Nv5ws7vqhcaz2UP3AfaqV6e 9EoLppbnlbP0E+gajjT8+aHb9EPidHdCCYavIordyJs3cC79/1Cy8ZUVGuH77dQaUO8t l9nhbJ/81fbgsSMr+T4f9rZ8uqFrbIIiyFlO8J+4MqP8epSSw7ufQx+gd+wSR4rW6Tio +IqA== X-Gm-Message-State: ABy/qLa+QnQllJ8U7aCojP6uWASJPRmYhapkqgCTM5ClxlX/uQkRcdTv oTOA5YVm0ZeawrHD+BMyPjFdVS9HSzMMGSIKMvXdJA== X-Received: by 2002:adf:e286:0:b0:313:dfb8:b4d0 with SMTP id v6-20020adfe286000000b00313dfb8b4d0mr10365023wri.66.1688927608768; Sun, 09 Jul 2023 11:33:28 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH 31/45] linux-user: Rewrite target_mprotect Date: Sun, 9 Jul 2023 19:29:13 +0100 Message-Id: <20230709182934.309468-62-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42c.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use 'last' variables instead of 'end' variables. When host page size > guest page size, detect when adjacent host pages have the same protection and merge that expanded host range into fewer syscalls. Signed-off-by: Richard Henderson Message-Id: <20230707204054.8792-15-richard.henderson@linaro.org> --- linux-user/mmap.c | 106 +++++++++++++++++++++++++++++----------------- 1 file changed, 67 insertions(+), 39 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index b2c2d85857..d02d74d279 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -120,8 +120,11 @@ static int target_to_host_prot(int prot) /* NOTE: all the constants are the HOST ones, but addresses are target. */ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) { - abi_ulong end, host_start, host_end, addr; - int prot1, ret, page_flags; + abi_ulong starts[3]; + abi_ulong lens[3]; + int prots[3]; + abi_ulong host_start, host_last, last; + int prot1, ret, page_flags, nranges; trace_target_mprotect(start, len, target_prot); @@ -132,63 +135,88 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) if (!page_flags) { return -TARGET_EINVAL; } - len = TARGET_PAGE_ALIGN(len); - end = start + len; - if (!guest_range_valid_untagged(start, len)) { - return -TARGET_ENOMEM; - } if (len == 0) { return 0; } + len = TARGET_PAGE_ALIGN(len); + if (!guest_range_valid_untagged(start, len)) { + return -TARGET_ENOMEM; + } + + last = start + len - 1; + host_start = start & qemu_host_page_mask; + host_last = HOST_PAGE_ALIGN(last) - 1; + nranges = 0; mmap_lock(); - host_start = start & qemu_host_page_mask; - host_end = HOST_PAGE_ALIGN(end); - if (start > host_start) { - /* handle host page containing start */ + + if (host_last - host_start < qemu_host_page_size) { + /* Single host page contains all guest pages: sum the prot. */ prot1 = target_prot; - for (addr = host_start; addr < start; addr += TARGET_PAGE_SIZE) { - prot1 |= page_get_flags(addr); + for (abi_ulong a = host_start; a < start; a += TARGET_PAGE_SIZE) { + prot1 |= page_get_flags(a); } - if (host_end == host_start + qemu_host_page_size) { - for (addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) { - prot1 |= page_get_flags(addr); + for (abi_ulong a = last; a < host_last; a += TARGET_PAGE_SIZE) { + prot1 |= page_get_flags(a + 1); + } + starts[nranges] = host_start; + lens[nranges] = qemu_host_page_size; + prots[nranges] = prot1; + nranges++; + } else { + if (host_start < start) { + /* Host page contains more than one guest page: sum the prot. */ + prot1 = target_prot; + for (abi_ulong a = host_start; a < start; a += TARGET_PAGE_SIZE) { + prot1 |= page_get_flags(a); + } + /* If the resulting sum differs, create a new range. */ + if (prot1 != target_prot) { + starts[nranges] = host_start; + lens[nranges] = qemu_host_page_size; + prots[nranges] = prot1; + nranges++; + host_start += qemu_host_page_size; } - end = host_end; } - ret = mprotect(g2h_untagged(host_start), qemu_host_page_size, - target_to_host_prot(prot1)); - if (ret != 0) { - goto error; + + if (last < host_last) { + /* Host page contains more than one guest page: sum the prot. */ + prot1 = target_prot; + for (abi_ulong a = last; a < host_last; a += TARGET_PAGE_SIZE) { + prot1 |= page_get_flags(a + 1); + } + /* If the resulting sum differs, create a new range. */ + if (prot1 != target_prot) { + host_last -= qemu_host_page_size; + starts[nranges] = host_last + 1; + lens[nranges] = qemu_host_page_size; + prots[nranges] = prot1; + nranges++; + } } - host_start += qemu_host_page_size; - } - if (end < host_end) { - prot1 = target_prot; - for (addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) { - prot1 |= page_get_flags(addr); + + /* Create a range for the middle, if any remains. */ + if (host_start < host_last) { + starts[nranges] = host_start; + lens[nranges] = host_last - host_start + 1; + prots[nranges] = target_prot; + nranges++; } - ret = mprotect(g2h_untagged(host_end - qemu_host_page_size), - qemu_host_page_size, target_to_host_prot(prot1)); - if (ret != 0) { - goto error; - } - host_end -= qemu_host_page_size; } - /* handle the pages in the middle */ - if (host_start < host_end) { - ret = mprotect(g2h_untagged(host_start), host_end - host_start, - target_to_host_prot(target_prot)); + for (int i = 0; i < nranges; ++i) { + ret = mprotect(g2h_untagged(starts[i]), lens[i], + target_to_host_prot(prots[i])); if (ret != 0) { goto error; } } - page_set_flags(start, start + len - 1, page_flags); + page_set_flags(start, last, page_flags); ret = 0; -error: + error: mmap_unlock(); return ret; } From patchwork Sun Jul 9 18:29:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700881 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4828453wrs; Sun, 9 Jul 2023 11:35:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlFfRWq6besV6a7uVJY6MNjNVNXNuJfCaq5Pka6YNUUZICXmpHLfmssGbSiFU+WCH12y8vo1 X-Received: by 2002:a0c:a999:0:b0:630:2e1:d555 with SMTP id a25-20020a0ca999000000b0063002e1d555mr9274197qvb.44.1688927754316; Sun, 09 Jul 2023 11:35:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927754; cv=none; d=google.com; s=arc-20160816; b=OFQXqMjNu2wV0hl+DqmzWCs/Ync1H+MVlqSxV5KrdY5y589FD2ool0OvYoIOBx6awi w112SJSYHltzWT+lfKbIf8wlMW4sED726pHZ9Gur5gBetE1Y1y6SRZh5Bu5Sk/38MxOQ pSUusPJopDBzirE/LJ6uM5Ioaucz03L8H62CMWv4iZuxT9DRoryJI765gpE0N3DslFrB 8/BDzh4NwXbnLD3UjATnG0xr/5pGLWYyPZW7hX7CnPCRx3zXVBEpxwtu0WCaaif3ITjt 7CsWcFNacJeumZiENEPUbyDCeHjRhW6xgw4En4hI83VlyIBUIeDfjVf/RLLfBehtk4Mb 6yJg== 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:cc:to :from:dkim-signature; bh=aO8i+PWWEj2wFULENv6+H9RCy3N3UL0z2bpJ1K4Mi2s=; fh=4nfr0hkxlMpWE4oToQ1q4rzQVecv6te3cGVRc3YFjiI=; b=EDa6Sl8/zHCMloW8SHf7IadrSfu/TMNsdKH5qgBtswt3zcnNXjfl1e6WYqV71dUpSP QIFA4Hy0ift+RElhn/BMUjQpCkjicKtHkdZmzbpolLTKRGYOwv3dxDNznpO44ZmqEpfn Nqe8bRvG60R3AXZgxZoG0pr6MlI2bn4+WQvlTbhquByDfpLqyz8h7t/q86Rc+S+RLyqJ N41D4r0c0KU/ZDG4HGI4qZqrERg958qcNvLUn235Tft7rd0rz9xiSgf4tNOx6SrdxF7e obfH07AsIwjmXRufKXlSoSVs6OOzwFzyN6lLTVvfWhITqiMGXEettmsMyWRZjcCZNpgJ 5zKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XmvrBllE; 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 d30-20020a0cb2de000000b00635f941ddc7si4698775qvf.57.2023.07.09.11.35.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:35:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XmvrBllE; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZEB-0004ev-SF; Sun, 09 Jul 2023 14:33:47 -0400 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 1qIZDy-0003Zg-ON for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:35 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZDx-0004GT-04 for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:34 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3143798f542so4034462f8f.2 for ; Sun, 09 Jul 2023 11:33:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927610; x=1691519610; 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=aO8i+PWWEj2wFULENv6+H9RCy3N3UL0z2bpJ1K4Mi2s=; b=XmvrBllEYIuse+EO/aSoasxM2KjC4/sZgIhKeFv+VAk7IHJ09hm8nY18PtVonNEHBQ 3ZYDhuDQ3tQPaVR0b7Lnmhu2BlkqKD9MR2cfVoXFp4rXwn/uUQqBs+xwojX9U/Xf474J ASpwMKyWqI1CTIespcEDe8kwRYo1bZIzL5btNGNqvbMkvaCWKfiHTQMTHwGfJEPBK0po z6bPGDPE/dj37RIRX4vFqIUAZDy1BB92gj3bxlq8/t6DhQMccLQfBT2RHlzLG9EO31uE 6OZMVd8mjgYCOoI0uY2CxEst5hkhxEmoV28LpxZSEuGqOvLQVCG0I9nNeB8gyhy1JN7B GS7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927610; x=1691519610; 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=aO8i+PWWEj2wFULENv6+H9RCy3N3UL0z2bpJ1K4Mi2s=; b=cafcNc5FPU7H9ouTR237MKcOoIWERZVG/HfE2Ktpwlb1bx+VOVGW2EKnXrs8/QmNQS rN4z30jY99tSRLR1hZVkodFiEIiohTrCBeJvLqo/M81r5CV/g2X2goMtXTU2XsmZ3eEl 5IwwubNSeywH5s6qCCqg+qkEJUPFCMzTB8NaHq+wJYaZyg9gDffkImQBl6QSJyB5mKuq 9XLXVSpvt4g8hI36UAGIAbinp2DeUri25cZ9yViX1ZflsJrIFC/uVJIDVgMAOQ5A7eMG HKj66VSrIiGJCAL5QFuttGOaAv0VvbbYsnNWZ6AmuEB6YYVtmvCIOBoLvUg1hXT4Tqsg Qj/g== X-Gm-Message-State: ABy/qLaBZpzrSgjuexsAd0HkkOdb1PaH5alW9Z60Ua6Y6gYDcI/7UNq/ 5/RXNHcNjCG0P8/wUjhPgXvOjCqwc5kDIsJSWDgQOw== X-Received: by 2002:adf:edc1:0:b0:313:ec05:3e30 with SMTP id v1-20020adfedc1000000b00313ec053e30mr8959198wro.45.1688927610331; Sun, 09 Jul 2023 11:33:30 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH 32/45] linux-user: Rewrite mmap_frag Date: Sun, 9 Jul 2023 19:29:15 +0100 Message-Id: <20230709182934.309468-64-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42d.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use 'last' variables instead of 'end' variables. Always zero MAP_ANONYMOUS fragments, which we previously failed to do if they were not writable; early exit in case we allocate a new page from the kernel, known zeros. Signed-off-by: Richard Henderson Message-Id: <20230707204054.8792-16-richard.henderson@linaro.org> --- linux-user/mmap.c | 123 +++++++++++++++++++++++----------------------- 1 file changed, 62 insertions(+), 61 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index d02d74d279..c4b2515271 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -222,73 +222,76 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) } /* map an incomplete host page */ -static int mmap_frag(abi_ulong real_start, - abi_ulong start, abi_ulong end, - int prot, int flags, int fd, off_t offset) +static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last, + int prot, int flags, int fd, off_t offset) { - abi_ulong real_end, addr; + abi_ulong real_last; void *host_start; - int prot1, prot_new; + int prot_old, prot_new; + int host_prot_old, host_prot_new; - real_end = real_start + qemu_host_page_size; - host_start = g2h_untagged(real_start); - - /* get the protection of the target pages outside the mapping */ - prot1 = 0; - for (addr = real_start; addr < real_end; addr++) { - if (addr < start || addr >= end) { - prot1 |= page_get_flags(addr); - } + if (!(flags & MAP_ANONYMOUS) + && (flags & MAP_TYPE) == MAP_SHARED + && (prot & PROT_WRITE)) { + /* + * msync() won't work with the partial page, so we return an + * error if write is possible while it is a shared mapping. + */ + errno = EINVAL; + return false; } - if (prot1 == 0) { - /* no page was there, so we allocate one */ + real_last = real_start + qemu_host_page_size - 1; + host_start = g2h_untagged(real_start); + + /* Get the protection of the target pages outside the mapping. */ + prot_old = 0; + for (abi_ulong a = real_start; a < start; a += TARGET_PAGE_SIZE) { + prot_old |= page_get_flags(a); + } + for (abi_ulong a = real_last; a > last; a -= TARGET_PAGE_SIZE) { + prot_old |= page_get_flags(a); + } + + if (prot_old == 0) { + /* + * Since !(prot_old & PAGE_VALID), there were no guest pages + * outside of the fragment we need to map. Allocate a new host + * page to cover, discarding whatever else may have been present. + */ void *p = mmap(host_start, qemu_host_page_size, target_to_host_prot(prot), flags | MAP_ANONYMOUS, -1, 0); if (p == MAP_FAILED) { - return -1; + return false; } - prot1 = prot; + prot_old = prot; } - prot1 &= PAGE_BITS; + prot_new = prot | prot_old; - prot_new = prot | prot1; - if (!(flags & MAP_ANONYMOUS)) { - /* - * msync() won't work here, so we return an error if write is - * possible while it is a shared mapping. - */ - if ((flags & MAP_TYPE) == MAP_SHARED && (prot & PROT_WRITE)) { - return -1; - } + host_prot_old = target_to_host_prot(prot_old); + host_prot_new = target_to_host_prot(prot_new); - /* adjust protection to be able to read */ - if (!(prot1 & PROT_WRITE)) { - mprotect(host_start, qemu_host_page_size, - target_to_host_prot(prot1) | PROT_WRITE); - } + /* Adjust protection to be able to write. */ + if (!(host_prot_old & PROT_WRITE)) { + host_prot_old |= PROT_WRITE; + mprotect(host_start, qemu_host_page_size, host_prot_old); + } - /* read the corresponding file data */ - if (pread(fd, g2h_untagged(start), end - start, offset) == -1) { - return -1; - } - - /* put final protection */ - if (prot_new != (prot1 | PROT_WRITE)) { - mprotect(host_start, qemu_host_page_size, - target_to_host_prot(prot_new)); - } + /* Read or zero the new guest pages. */ + if (flags & MAP_ANONYMOUS) { + memset(g2h_untagged(start), 0, last - start + 1); } else { - if (prot_new != prot1) { - mprotect(host_start, qemu_host_page_size, - target_to_host_prot(prot_new)); - } - if (prot_new & PROT_WRITE) { - memset(g2h_untagged(start), 0, end - start); + if (pread(fd, g2h_untagged(start), last - start + 1, offset) == -1) { + return false; } } - return 0; + + /* Put final protection */ + if (host_prot_new != host_prot_old) { + mprotect(host_start, qemu_host_page_size, host_prot_new); + } + return true; } #if HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 64 @@ -681,27 +684,25 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, if (start > real_start) { if (real_end == real_start + qemu_host_page_size) { /* one single host page */ - ret = mmap_frag(real_start, start, end, - target_prot, flags, fd, offset); - if (ret == -1) { + if (!mmap_frag(real_start, start, end - 1, + target_prot, flags, fd, offset)) { goto fail; } goto the_end1; } - ret = mmap_frag(real_start, start, real_start + qemu_host_page_size, - target_prot, flags, fd, offset); - if (ret == -1) { + if (!mmap_frag(real_start, start, + real_start + qemu_host_page_size - 1, + target_prot, flags, fd, offset)) { goto fail; } real_start += qemu_host_page_size; } /* handle the end of the mapping */ if (end < real_end) { - ret = mmap_frag(real_end - qemu_host_page_size, - real_end - qemu_host_page_size, end, - target_prot, flags, fd, - offset + real_end - qemu_host_page_size - start); - if (ret == -1) { + if (!mmap_frag(real_end - qemu_host_page_size, + real_end - qemu_host_page_size, end - 1, + target_prot, flags, fd, + offset + real_end - qemu_host_page_size - start)) { goto fail; } real_end -= qemu_host_page_size; From patchwork Sun Jul 9 18:29:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700900 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4829290wrs; Sun, 9 Jul 2023 11:39:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlFDnFU+QRFcouxepIFk5LDkPMkyIrWH86dexbi5US8y2G06r3WVJXs4C1sCjjmZLsAHODoQ X-Received: by 2002:a05:620a:4146:b0:767:954:a752 with SMTP id k6-20020a05620a414600b007670954a752mr12803876qko.73.1688927966219; Sun, 09 Jul 2023 11:39:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927966; cv=none; d=google.com; s=arc-20160816; b=hhuAwlYnnd8GhaMe4KuCRMTwOobsweTSr4qrP5p+phS4Mntllm35tCJNUSFVAiX1jg LUj35C1LICBDvck5yAbeb5J26O1RV1w6GeNdhHN/CKQn5XbqNZOTtpGwF2P2O31DQ5UG NBkPEto73IihvDUkXTrqNvFdZiwN8U/3hX7CGfjFNZePwENQwWwz+SjXhGRQzQSyMpdd QLzcPl6ew+EXeO07gigW1B2lQ/4vIRcM6gK9IfRyiqKd3Hic30i/cxajDj8zuhn7X8Bd jVJppeG4Ripx5NycB/ZEk9IDeIilZlLCkQ/2ilgrmlTaze8rExB+UTqwENpOn0UjTz/C gZzg== 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:cc:to :from:dkim-signature; bh=UNvrPJBGJx5dGrfGxip7sDDn/+xiNFreEIZcy5LuLWI=; fh=3IEiF/YPZ00TE94rna3Orj/L+TRFhpuNf7ElRJz3ubE=; b=LpibeRmmh0IYlmEr6LDB2LDglQy9D8Cv0NYaheJ/SOd1hb3dviGx2iXv6J2VtgKsHd ivlEYZoduVHHk3TIid0eDnXx5zALEjikM8HH0QrLjpEEBYGZ41F+zzjl2dfQ6vxFu5qw MLAzezJ/TemMm4vgyn2X1rqs/ewb82A1Tx21Z9QHvEsjRCubPni7uCT3rccsOGzXMISZ ZwuR74PFfAMR53mvZMgKKvJs4+27FX3mxImYegSCAs4sRgXnGZDWVM4uuHAWGbcQAud2 b6G+0711wZnAdIg7K0OCJ2ZRO9voidZaLX2CGVKphGuEpEEwH8RSzVioEtiWlrwnJ4zX cwtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tWw1yDr1; 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 pj16-20020a05620a1d9000b00766fd049965si5146758qkn.286.2023.07.09.11.39.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:39:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tWw1yDr1; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZEF-0005Jb-Ae; Sun, 09 Jul 2023 14:33:51 -0400 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 1qIZDz-0003aF-T1 for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:35 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZDx-0004H1-T2 for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:35 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fbc244d384so38097945e9.0 for ; Sun, 09 Jul 2023 11:33:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927612; x=1691519612; 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=UNvrPJBGJx5dGrfGxip7sDDn/+xiNFreEIZcy5LuLWI=; b=tWw1yDr184gNGbHwm5grNX7bEX6MfUXs9/p9iqJGvW3lz972IUH9JKjCgGN66O/cx0 nZe6TWtt+lhMpU26GDt/gftrlSdT+pkrPStCYTbOiUYNeyBVn///o69CheonPMTeljdY b0L6K+f1RZyv3brTmOJYku4lFUzWWlDOh9eg3V+s62gOjxkW/chKe7O+YK+A1blyxx06 pddD4bUnzEonYtKVz0+EqWssMoPe7SsPGnXlouuVa6F1eIwkPme+wwY1Y8ZTqnDW5GQH p9LZThqdsQPDG2/c3gyFVZ0i/eYVXP7rGNoQPGhVK6D48/sxi4EYFlfLzgcggJU3s77N ggZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927612; x=1691519612; 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=UNvrPJBGJx5dGrfGxip7sDDn/+xiNFreEIZcy5LuLWI=; b=TqJcwprWDwKjqSvTPVSjPKurDD9QQmrwO18idsJZBO/Wfqwh+DGJErhSWvxxXQPJXY aloWBhNwKM54YZkBLFyW2u4phf1d/zLXBfKTb8dEs/dOb2NzDqdmg3dwiCZI4GkU0HBL AdvtJ6jYFyqL/Lm3mzvk3HCQPiVxDmxGUKISzOgsG/b95s3CA2IvddvvxJCK1iRQEHxx tc2524Us6t45FesapTmwalVdBRDpSFST/fijJVnum5O1mkPUXrHD7vpQJSw+53bCB084 ov758089t26rs3ojLHbVBeR5bZ7YkCEl0lC/MZKPprONqxjz4YdocRiri83LclRKHkxD Lxsg== X-Gm-Message-State: ABy/qLZMmR9LCEfw2H6X7bt8agtIVGi0vkXkd3nSK5eWAZCgla3kIQ7x VYSaSW7hXc6zqtqKB/M9cDvk4ywHImoZnW74ScVXtg== X-Received: by 2002:adf:ee4a:0:b0:314:11d7:c919 with SMTP id w10-20020adfee4a000000b0031411d7c919mr8866085wro.49.1688927612628; Sun, 09 Jul 2023 11:33:32 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 33/37] target/riscv: Use aesdec_ISB_ISR_IMC_AK Date: Sun, 9 Jul 2023 19:29:18 +0100 Message-Id: <20230709182934.309468-67-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32e.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This implements the AES64DSM instruction. This was the last use of aes64_operation and its support macros, so remove them all. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/riscv/crypto_helper.c | 101 ++++------------------------------- 1 file changed, 10 insertions(+), 91 deletions(-) diff --git a/target/riscv/crypto_helper.c b/target/riscv/crypto_helper.c index c036fe8632..99d85a6188 100644 --- a/target/riscv/crypto_helper.c +++ b/target/riscv/crypto_helper.c @@ -104,98 +104,8 @@ target_ulong HELPER(aes32dsi)(target_ulong rs1, target_ulong rs2, return aes32_operation(shamt, rs1, rs2, false, false); } -#define BY(X, I) ((X >> (8 * I)) & 0xFF) - -#define AES_SHIFROWS_LO(RS1, RS2) ( \ - (((RS1 >> 24) & 0xFF) << 56) | (((RS2 >> 48) & 0xFF) << 48) | \ - (((RS2 >> 8) & 0xFF) << 40) | (((RS1 >> 32) & 0xFF) << 32) | \ - (((RS2 >> 56) & 0xFF) << 24) | (((RS2 >> 16) & 0xFF) << 16) | \ - (((RS1 >> 40) & 0xFF) << 8) | (((RS1 >> 0) & 0xFF) << 0)) - -#define AES_INVSHIFROWS_LO(RS1, RS2) ( \ - (((RS2 >> 24) & 0xFF) << 56) | (((RS2 >> 48) & 0xFF) << 48) | \ - (((RS1 >> 8) & 0xFF) << 40) | (((RS1 >> 32) & 0xFF) << 32) | \ - (((RS1 >> 56) & 0xFF) << 24) | (((RS2 >> 16) & 0xFF) << 16) | \ - (((RS2 >> 40) & 0xFF) << 8) | (((RS1 >> 0) & 0xFF) << 0)) - -#define AES_MIXBYTE(COL, B0, B1, B2, B3) ( \ - BY(COL, B3) ^ BY(COL, B2) ^ AES_GFMUL(BY(COL, B1), 3) ^ \ - AES_GFMUL(BY(COL, B0), 2)) - -#define AES_MIXCOLUMN(COL) ( \ - AES_MIXBYTE(COL, 3, 0, 1, 2) << 24 | \ - AES_MIXBYTE(COL, 2, 3, 0, 1) << 16 | \ - AES_MIXBYTE(COL, 1, 2, 3, 0) << 8 | AES_MIXBYTE(COL, 0, 1, 2, 3) << 0) - -#define AES_INVMIXBYTE(COL, B0, B1, B2, B3) ( \ - AES_GFMUL(BY(COL, B3), 0x9) ^ AES_GFMUL(BY(COL, B2), 0xd) ^ \ - AES_GFMUL(BY(COL, B1), 0xb) ^ AES_GFMUL(BY(COL, B0), 0xe)) - -#define AES_INVMIXCOLUMN(COL) ( \ - AES_INVMIXBYTE(COL, 3, 0, 1, 2) << 24 | \ - AES_INVMIXBYTE(COL, 2, 3, 0, 1) << 16 | \ - AES_INVMIXBYTE(COL, 1, 2, 3, 0) << 8 | \ - AES_INVMIXBYTE(COL, 0, 1, 2, 3) << 0) - static const AESState aes_zero = { }; -static inline target_ulong aes64_operation(target_ulong rs1, target_ulong rs2, - bool enc, bool mix) -{ - uint64_t RS1 = rs1; - uint64_t RS2 = rs2; - uint64_t result; - uint64_t temp; - uint32_t col_0; - uint32_t col_1; - - if (enc) { - temp = AES_SHIFROWS_LO(RS1, RS2); - temp = (((uint64_t)AES_sbox[(temp >> 0) & 0xFF] << 0) | - ((uint64_t)AES_sbox[(temp >> 8) & 0xFF] << 8) | - ((uint64_t)AES_sbox[(temp >> 16) & 0xFF] << 16) | - ((uint64_t)AES_sbox[(temp >> 24) & 0xFF] << 24) | - ((uint64_t)AES_sbox[(temp >> 32) & 0xFF] << 32) | - ((uint64_t)AES_sbox[(temp >> 40) & 0xFF] << 40) | - ((uint64_t)AES_sbox[(temp >> 48) & 0xFF] << 48) | - ((uint64_t)AES_sbox[(temp >> 56) & 0xFF] << 56)); - if (mix) { - col_0 = temp & 0xFFFFFFFF; - col_1 = temp >> 32; - - col_0 = AES_MIXCOLUMN(col_0); - col_1 = AES_MIXCOLUMN(col_1); - - result = ((uint64_t)col_1 << 32) | col_0; - } else { - result = temp; - } - } else { - temp = AES_INVSHIFROWS_LO(RS1, RS2); - temp = (((uint64_t)AES_isbox[(temp >> 0) & 0xFF] << 0) | - ((uint64_t)AES_isbox[(temp >> 8) & 0xFF] << 8) | - ((uint64_t)AES_isbox[(temp >> 16) & 0xFF] << 16) | - ((uint64_t)AES_isbox[(temp >> 24) & 0xFF] << 24) | - ((uint64_t)AES_isbox[(temp >> 32) & 0xFF] << 32) | - ((uint64_t)AES_isbox[(temp >> 40) & 0xFF] << 40) | - ((uint64_t)AES_isbox[(temp >> 48) & 0xFF] << 48) | - ((uint64_t)AES_isbox[(temp >> 56) & 0xFF] << 56)); - if (mix) { - col_0 = temp & 0xFFFFFFFF; - col_1 = temp >> 32; - - col_0 = AES_INVMIXCOLUMN(col_0); - col_1 = AES_INVMIXCOLUMN(col_1); - - result = ((uint64_t)col_1 << 32) | col_0; - } else { - result = temp; - } - } - - return result; -} - target_ulong HELPER(aes64esm)(target_ulong rs1, target_ulong rs2) { AESState t; @@ -228,7 +138,16 @@ target_ulong HELPER(aes64ds)(target_ulong rs1, target_ulong rs2) target_ulong HELPER(aes64dsm)(target_ulong rs1, target_ulong rs2) { - return aes64_operation(rs1, rs2, false, true); + AESState t, z = { }; + + /* + * This instruction does not include a round key, + * so supply a zero to our primitive. + */ + t.d[HOST_BIG_ENDIAN] = rs1; + t.d[!HOST_BIG_ENDIAN] = rs2; + aesdec_ISB_ISR_IMC_AK(&t, &t, &z, false); + return t.d[HOST_BIG_ENDIAN]; } target_ulong HELPER(aes64ks2)(target_ulong rs1, target_ulong rs2) From patchwork Sun Jul 9 18:29:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700887 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4828893wrs; Sun, 9 Jul 2023 11:37:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlER2/4gyauJamrXFSWYeKcZ75//wuLGDqGsTbYAx0fFRkfsyf8MZkrdl6zeRBT+N4RvKe6v X-Received: by 2002:a0c:b305:0:b0:634:a1a5:c7bc with SMTP id s5-20020a0cb305000000b00634a1a5c7bcmr9303631qve.20.1688927873136; Sun, 09 Jul 2023 11:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927873; cv=none; d=google.com; s=arc-20160816; b=P/oMzH9SlERmvUXd4Id5tkG6HUM1gldPFJzSYzXcpG2At4/2aDMgncNjs20pMuLHdj TSktyM/cBqV3pkGrkUjutXtHCMK2MruH8EJFw+ogBBmSzLRffVQEWPU+PLkovWeLaUjY AqvC6nSTJGRvPsIfcLiPbm1xM2Nefjw9Im7xktjsAbIZ/tQClmfVJsMFMr/tYTpS1ZDi 5pzrwKAenEDyBH8Bl0uWsa/tLuFWeBff549ediDrjl8TVNNAIFr6SrJTrAmxDf+h9rGg YjNPSkAqXAi0EOdU/SHjfEcUX5WC8AkmYBYgj2w3SZ4DqGZjSp4gCzTA+1QBfsxDjPnL 5PIw== 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:cc:to :from:dkim-signature; bh=LO6Chl8aQYLOaHq+kw102b8WCIYofNouZUqxF+V9shk=; fh=lMWaYJWKNNp5se7C5JIc/IAy1MaLsIKSBhk4MhqnayU=; b=qscHWcZzKPlW8E9CxYUrOdyvnitvW2RB8fcKW2+o4zmh74zMkm8jqkMbbK4R+BNFmG qkwPmU9LA+AESspXDP5YTNvK6q6dA3FaqQ0JmQh5skGEojO+h0xbyhl4u8EXKfO3J2vR 1N0P0mFeVDGWafADe37YJUYoGc6ALTUyaMelesJqWmwdNoeF17lalVrJ35J3grf+STL1 CwHm1HFQoAq29TpQsVyeuLaIGQzgxTh1UVELVxchqae76EbXfIHrWmS3e1QttaKhoK3B WHkSk2IltUscrysw+ux9ELc319nkhVY4zBF4FP+2/QZYXko6vyveC86qHlBueEx6fqtU yz8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="YUquXa/b"; 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 y5-20020a0cc545000000b0062fe5397100si4833381qvi.144.2023.07.09.11.37.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:37:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="YUquXa/b"; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZEA-0004ak-EA; Sun, 09 Jul 2023 14:33:46 -0400 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 1qIZE1-0003fr-9s for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:38 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZDz-0004Hn-Mu for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:37 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-313fb7f0f80so3705621f8f.2 for ; Sun, 09 Jul 2023 11:33:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927614; x=1691519614; 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=LO6Chl8aQYLOaHq+kw102b8WCIYofNouZUqxF+V9shk=; b=YUquXa/bAZ/dDSgopJMyVJK4PI5dw/yTfgXIQr7FcTnqAXPegY+ZqIUMXVXi1NumoK wBoVhjMxCesXNJ2iUhBQbvECh73CY3U1P4gc8Dw79xBboDIE9ZBiDqyAqZ+3NZbVnQMz JzCqGcK2/0WAdTeGfRb1CQ2SjFjSlmSQjbXMb9iXbx7rCWnlxYiwYODOHWG8qRcIF0wm JtWFDCI7ke0G5UmDKShKkkv+JZcia2sZrMBhNALBvN4w10OCqhD2o+pQjFevNqK7F0Ab KeiR33tg5WNvVgi/ezf10PPm39bsZX/9PmJugMnHzZluhdP8pUbdwsV5hzJz/DiJV26j y/7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927614; x=1691519614; 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=LO6Chl8aQYLOaHq+kw102b8WCIYofNouZUqxF+V9shk=; b=dO1rKYlppjmzO3D0wnHHXAWDJ/ohAWVG/0F8vSVx3IeSXiTdgftSkJLo0odwOkYXSn x3DmN5y3aO58EGuSjir13cdWIExM+1jDXMrV4l7Ujubg3QySVUn01JniqYX+UaVQaZ8H Yi6/F0zu9847cuJ1Y9LmSW0L8p5FE964dVHIkzKgOdpIN39DlNZ3KtETNH31jreDaiy6 Z8LkaZmgumEHdkRt00RilRboKxJvBffcVzF8m6AC8u2ecZiTt1mbw8qByThSfokoLjiA uz6kA1kps21V4jHC6UERsOp4JIecsrvnWJ5N0GX2mM27x0Iij1FMfeb/sqw+CsJRivKT /WZA== X-Gm-Message-State: ABy/qLaaqYveHH9eMdLHSiDgkL0aCjHKFSUxeszNqNei3HGtUdBiLnv5 wxUkOYbrogy5pct07oSUSP44PDAtTd//mUhP3TFMoQ== X-Received: by 2002:a5d:528e:0:b0:30f:ca58:a00d with SMTP id c14-20020a5d528e000000b0030fca58a00dmr7873346wrv.45.1688927614386; Sun, 09 Jul 2023 11:33:34 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= Subject: [PULL 34/37] crypto: Remove AES_shifts, AES_ishifts Date: Sun, 9 Jul 2023 19:29:20 +0100 Message-Id: <20230709182934.309468-69-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x431.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These arrays are no longer used, replaced by AES_SH_*, AES_ISH_*. Acked-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/crypto/aes.h | 4 ---- crypto/aes.c | 14 -------------- 2 files changed, 18 deletions(-) diff --git a/include/crypto/aes.h b/include/crypto/aes.h index 24b073d569..aa8b54065d 100644 --- a/include/crypto/aes.h +++ b/include/crypto/aes.h @@ -30,10 +30,6 @@ void AES_decrypt(const unsigned char *in, unsigned char *out, extern const uint8_t AES_sbox[256]; extern const uint8_t AES_isbox[256]; -/* AES ShiftRows and InvShiftRows */ -extern const uint8_t AES_shifts[16]; -extern const uint8_t AES_ishifts[16]; - /* AES MixColumns, for use with rot32. */ extern const uint32_t AES_mc_rot[256]; diff --git a/crypto/aes.c b/crypto/aes.c index c765f11c1e..00e16d3f92 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -114,23 +114,9 @@ const uint8_t AES_isbox[256] = { /* AES ShiftRows, for complete unrolling. */ #define AES_SH(X) (((X) * 5) & 15) -const uint8_t AES_shifts[16] = { - AES_SH(0x0), AES_SH(0x1), AES_SH(0x2), AES_SH(0x3), - AES_SH(0x4), AES_SH(0x5), AES_SH(0x6), AES_SH(0x7), - AES_SH(0x8), AES_SH(0x9), AES_SH(0xA), AES_SH(0xB), - AES_SH(0xC), AES_SH(0xD), AES_SH(0xE), AES_SH(0xF), -}; - /* AES InvShiftRows, for complete unrolling. */ #define AES_ISH(X) (((X) * 13) & 15) -const uint8_t AES_ishifts[16] = { - AES_ISH(0x0), AES_ISH(0x1), AES_ISH(0x2), AES_ISH(0x3), - AES_ISH(0x4), AES_ISH(0x5), AES_ISH(0x6), AES_ISH(0x7), - AES_ISH(0x8), AES_ISH(0x9), AES_ISH(0xA), AES_ISH(0xB), - AES_ISH(0xC), AES_ISH(0xD), AES_ISH(0xE), AES_ISH(0xF), -}; - /* * MixColumns lookup table, for use with rot32. */ From patchwork Sun Jul 9 18:29:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700913 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4830129wrs; Sun, 9 Jul 2023 11:42:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlEhanuhIT9HV94RnYadzyXAohqWe0BDVJrIAd3yGSMp8/NWh/IlHqCa91vxx663I4+hXpLd X-Received: by 2002:a05:620a:1a1e:b0:765:acf7:9572 with SMTP id bk30-20020a05620a1a1e00b00765acf79572mr10727275qkb.34.1688928168359; Sun, 09 Jul 2023 11:42:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688928168; cv=none; d=google.com; s=arc-20160816; b=H3UfVJRY+FtBVH8DOUYbXiNVoZDMgKE7tFxx8WLZhENTiYgGoHQoqujb9kk/WsL/Ad 4YLyAjcdqp4jgaqqI/NMvadSDUhs182ipB9aI72kn/sDu4jppRCXawBbsUtrqRU1kz5e nnfFX70XTWzlvK5H1uoS5QcfClbgUgmb8Dgj+ubW/Nf1V8vh2wSx3ITgkZqZyF7xdfPX glGcQzsvendHhsT8CFNmPzeHv456rdXU/AbYGRt28y0OOXwwltbotCGV2AFM12dMyxAD HxM6Zzk+tyTgIO40dV4UIlk5oRBSfJZ8+PDb2KurfYCgHxTDz92wwUahuu4AUHlrHOcU xN7w== 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:cc:to :from:dkim-signature; bh=5+vFU351RDeVAwRNg/WDopVOnzTmK+ZtjZmF1Bh7abU=; fh=4nfr0hkxlMpWE4oToQ1q4rzQVecv6te3cGVRc3YFjiI=; b=mwX94gZg6UO4LzcbITWLNr5OibCnZdLqFk0ulPHZnzZdtDDdNkCk9KJNrjxrEfPS4g ESIL/fJbgQ8RrRBvzOiK4uBRYHpVsrXipst6iIjJ1vfvDbIZFzFJjTyR7cr2Tz5lt+Wu lFNkmUOipmGJeQDjQ5ZZnfVd7m4ywpOrMMwJZ1BqSsupjkH7do/Et/kX3iWHk4FWVsfp LtlmMJshDbeGyoql4fUc5YgrI8gpLbOqJx5jwON30GPikekQdvm8kAajyO/xNKOhmXMx AZy1M/+/a8cAvz08nZWtq/LExu2JecyF8bpmdaAQIdJb9DlmBEaDSjvz19ry9w1H5kJf PHdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eb82pVZK; 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 n11-20020a05620a152b00b00763d5d29c89si4978608qkk.354.2023.07.09.11.42.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:42:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eb82pVZK; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZEE-0005Cf-FL; Sun, 09 Jul 2023 14:33:50 -0400 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 1qIZE2-0003on-UR for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:39 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZE1-0004IG-AW for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:38 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-31427ddd3fbso3834985f8f.0 for ; Sun, 09 Jul 2023 11:33:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927616; x=1691519616; 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=5+vFU351RDeVAwRNg/WDopVOnzTmK+ZtjZmF1Bh7abU=; b=eb82pVZK0qXY2jf957nkIICog1cf/S3GbH4wZXYGvKqx+3bwq3ywxeMG0GIruaw+sD LeHv3Ybddcgx/EFHb/6e7f1C8a0IvqCtWUl5ezTGJnX7Q2YyIlbNzqDwqZz1n3HRQBFU 4RbSSVKX3A+80lEeGxzZYIc9JGu96lSWt3MkZ83MZLm76ItERgz6MakhPD59fXWI0uv2 UiOAi4YgwsmekL9+IocbKi3itOAJOIDnjJkRpoPpIQGd7pDCjx49Tk7vnDHQY0Ifcyel fDsxpjLGRaJxoTpssVy7V/PR3Ys3PekYtytbTml0RPDPvd0ysfPaitGA8ZGm6huRG0XE KLoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927616; x=1691519616; 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=5+vFU351RDeVAwRNg/WDopVOnzTmK+ZtjZmF1Bh7abU=; b=Jjpicz6+1YoxABuOOFhRPROz1FzvKMvNbK2xamAvqORjbmarL6jObevFikk/qvjQfv zEv6689ux4g9L4PbfQRs8mTeSDMkkUD9MfkMLdQ3fPAEITPRFvLh2k5xtQBca8zBpDb8 4bocrvLxj0h3j6Q78f3Hcm88lyA/EhxjwEvxMGm28w6cNTBT1JDHcec5pjlINxaKQ+IC vhOCgDQ6yo/NmNCt4xL+3grZ1ehkhenXarymCAQP1g159wJqzt8zFMN82Vq6SgVn6kBv WwYl7fYuGaPzYlB//BBQAoLgOahtK0fwgAQ3NDjPjEA6bllqLBaW/XkbzRvocC/i6M1l NT3Q== X-Gm-Message-State: ABy/qLaf3A0dKV1GZSuZKeXKD+yroYHfYPVLo9TVus3g0zSpdqWvHaC4 0O/zYSGMKMSnzPmZo6NdAYXbSMyfK169kosSIOkxAg== X-Received: by 2002:a05:6000:1b86:b0:314:34dd:aaec with SMTP id r6-20020a0560001b8600b0031434ddaaecmr9477319wru.8.1688927616087; Sun, 09 Jul 2023 11:33:36 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH 35/45] linux-user: Use page_find_range_empty for mmap_find_vma_reserved Date: Sun, 9 Jul 2023 19:29:22 +0100 Message-Id: <20230709182934.309468-71-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42b.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use the interval tree to find empty space, rather than probing each page in turn. Signed-off-by: Richard Henderson Message-Id: <20230707204054.8792-19-richard.henderson@linaro.org> --- linux-user/mmap.c | 52 ++++++----------------------------------------- 1 file changed, 6 insertions(+), 46 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index c4b2515271..738b9b797d 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -318,55 +318,15 @@ unsigned long last_brk; static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size, abi_ulong align) { - abi_ulong addr, end_addr, incr = qemu_host_page_size; - int prot; - bool looped = false; + target_ulong ret; - if (size > reserved_va) { - return (abi_ulong)-1; + ret = page_find_range_empty(start, reserved_va, size, align); + if (ret == -1 && start > mmap_min_addr) { + /* Restart at the beginning of the address space. */ + ret = page_find_range_empty(mmap_min_addr, start - 1, size, align); } - /* Note that start and size have already been aligned by mmap_find_vma. */ - - end_addr = start + size; - /* - * Start at the top of the address space, ignoring the last page. - * If reserved_va == UINT32_MAX, then end_addr wraps to 0, - * throwing the rest of the calculations off. - * TODO: rewrite using last_addr instead. - * TODO: use the interval tree instead of probing every page. - */ - if (start > reserved_va - size) { - end_addr = ((reserved_va - size) & -align) + size; - looped = true; - } - - /* Search downward from END_ADDR, checking to see if a page is in use. */ - addr = end_addr; - while (1) { - addr -= incr; - if (addr > end_addr) { - if (looped) { - /* Failure. The entire address space has been searched. */ - return (abi_ulong)-1; - } - /* Re-start at the top of the address space (see above). */ - addr = end_addr = ((reserved_va - size) & -align) + size; - looped = true; - } else { - prot = page_get_flags(addr); - if (prot) { - /* Page in use. Restart below this page. */ - addr = end_addr = ((addr - size) & -align) + size; - } else if (addr && addr + size == end_addr) { - /* Success! All pages between ADDR and END_ADDR are free. */ - if (start == mmap_next_start) { - mmap_next_start = addr; - } - return addr; - } - } - } + return ret; } /* From patchwork Sun Jul 9 18:29:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700893 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4829110wrs; Sun, 9 Jul 2023 11:38:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlEJ4KV4duKjtUqS3RqWRDuWgMGk9JLpMf5ZDgKavHOt/jOUSRai4PnW7PNLjw4Mmb1aZ1Kz X-Received: by 2002:a0c:c403:0:b0:635:e0dd:db42 with SMTP id r3-20020a0cc403000000b00635e0dddb42mr8373173qvi.27.1688927924474; Sun, 09 Jul 2023 11:38:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927924; cv=none; d=google.com; s=arc-20160816; b=CdtoMrSpazlD3322HPE813V6ibupFaCvLR4GHZJxtUrFd/0M7210Ck5pm7Dj7jnZ30 OxGCpInrK4rzHdGf4ghMc/asDyH1aQMxInn3ZxsQjQ/fWQQGzOm18uwo9b2NRfoWglGU wnesZcl0UgShnJ48DvHhRvFWQ79QlXGxFVnwc2aXcrSBKbuhIQlB6MdpKr1j8Xcmoau6 QTyG+wjxOv0exwbnkKmmi9kd/bH9nH2KQGdnoNmFjiJ2VmLq+D5ceDK/z7nTcrA0kD5P +EvbHQwivK8TeT1ZzIQZbe7KcTKW1I3WSkteQuMrJq+U5gtwaAPekuRK5oZL9L2UshWX cJ2g== 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:cc:to :from:dkim-signature; bh=jfvLV6T2p9fP56/v/Xia6iQ7yK2dQ6zBkNiykDOKhfw=; fh=3IEiF/YPZ00TE94rna3Orj/L+TRFhpuNf7ElRJz3ubE=; b=JQUGKgA95gaiS2x61QVNRYSEcPdUeTQBbhSh1HtmCCkzMqJeCTvrq+1A3vjeLNSEGi DhfatwyZzKG15PRdZjDWPc0l4N8kxfczxFis9PzSbEeRYtUeMBP6tfAfvgfIMS7hwt/a /wMlkyOBFQD52XuDIaLDydJuZ73U/e1hTc71YS6YY5XSUTmqyZBcTaFWOVNPTeqRa5zE KAB4OxW8hT/zRW0i8vegD1FC0TWJlboKKTtiJ1+DWti6QKG8w+BE8+9bdJ/lnnOJcvRb pTjgC8751LpfyRLkJUO2KBJcfOoKT2Vwiac7WQj57qVg8NUbFQHq/A5r72ldnynnDB9+ YZxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Iu769+Ce; 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 p27-20020a05620a15fb00b0076776a86721si5055245qkm.297.2023.07.09.11.38.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:38:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Iu769+Ce; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZEC-0004ms-09; Sun, 09 Jul 2023 14:33:48 -0400 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 1qIZE8-0004KA-1u for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:44 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZE3-0004Iz-85 for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:40 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-3128fcd58f3so4042883f8f.1 for ; Sun, 09 Jul 2023 11:33:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927618; x=1691519618; 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=jfvLV6T2p9fP56/v/Xia6iQ7yK2dQ6zBkNiykDOKhfw=; b=Iu769+CeDmbhxeaP4f3c/BUQzMW00to6eQPH8l9S4Twt9ml4jNywDOIozg16e/cLuj Y3gdayKKPxma+e1VR2wileGpd3hvnI3CfJ/9DLff9lKI4RqfEeJN26+QXnGmDM27ZXw2 S5/Ho/+5Hcrf/bZ9BZvfhdh7pYXPRhf15NAFjwYvbDvKM+BW64HZ3fY3MVhsf3tJstOH b5NDev7Rog5h/QEcxgFn9Z0Gtc3x0r/HDs2L565wle4XFLOKZSNPPT4++0k8fYJuIrrh 2guCMO283HZ/eYb+OQwodWXdRmAXOqevFVJp49tC8ph6hRIV2E5gq39Y7cvtlt9S6cyg uM5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927618; x=1691519618; 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=jfvLV6T2p9fP56/v/Xia6iQ7yK2dQ6zBkNiykDOKhfw=; b=kil+BwgTdJViItSq0KorjLGF0t4d9Kf9wkSY3SH2hbPxKzQLMvvOL3zqkGwcP1RCgT Z9ZxVeZLAxfWorLXW20h0uZc5Ys/16p8BLNJw2Dgh4OBRTkUsmOXoVt7iV4DV57DpBHv CZIMu/rxMOBRhZIa87q2aVde+EAfQRGempa/OdoqiE5n/7hp//Rr25t47qd8AzAlqJcF +peylS+FrH4hH0/c5TYOQLYH6vEUYIxU4uhG+Af2WuonrAy1BmIcVGhVhaWRfHvcg012 eb6BMdtsvnV5Hvn1V5K+uv4ZKiGD1Imcd7iAx/csCdyyjxSmWm6yBWnbwmoqsACCMS4u ajaA== X-Gm-Message-State: ABy/qLaKyT7RSxORhzwlXYdJjCzoMnv9mjTcri2JMrVlifJsXqG3CpXH i00xPwUxjClI1k/VWzudnZI3ttqnx+0tPvmmS5Ly0A== X-Received: by 2002:adf:ed05:0:b0:313:f0d7:a43 with SMTP id a5-20020adfed05000000b00313f0d70a43mr9922790wro.23.1688927617982; Sun, 09 Jul 2023 11:33:37 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 36/45] linux-user: Use 'last' instead of 'end' in target_mmap Date: Sun, 9 Jul 2023 19:29:24 +0100 Message-Id: <20230709182934.309468-73-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x433.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Complete the transition within the mmap functions to a formulation that does not overflow at the end of the address space. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230707204054.8792-20-richard.henderson@linaro.org> --- linux-user/mmap.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 738b9b797d..bb9cbe52cd 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -456,8 +456,8 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, int flags, int fd, off_t offset) { - abi_ulong ret, end, real_start, real_end, retaddr, host_len, - passthrough_start = -1, passthrough_end = -1; + abi_ulong ret, last, real_start, real_last, retaddr, host_len; + abi_ulong passthrough_start = -1, passthrough_last = 0; int page_flags; off_t host_offset; @@ -581,29 +581,30 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, host_start += offset - host_offset; } start = h2g(host_start); + last = start + len - 1; passthrough_start = start; - passthrough_end = start + len; + passthrough_last = last; } else { if (start & ~TARGET_PAGE_MASK) { errno = EINVAL; goto fail; } - end = start + len; - real_end = HOST_PAGE_ALIGN(end); + last = start + len - 1; + real_last = HOST_PAGE_ALIGN(last) - 1; /* * Test if requested memory area fits target address space * It can fail only on 64-bit host with 32-bit target. * On any other target/host host mmap() handles this error correctly. */ - if (end < start || !guest_range_valid_untagged(start, len)) { + if (last < start || !guest_range_valid_untagged(start, len)) { errno = ENOMEM; goto fail; } /* Validate that the chosen range is empty. */ if ((flags & MAP_FIXED_NOREPLACE) - && !page_check_range_empty(start, end - 1)) { + && !page_check_range_empty(start, last)) { errno = EEXIST; goto fail; } @@ -642,9 +643,9 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, /* handle the start of the mapping */ if (start > real_start) { - if (real_end == real_start + qemu_host_page_size) { + if (real_last == real_start + qemu_host_page_size - 1) { /* one single host page */ - if (!mmap_frag(real_start, start, end - 1, + if (!mmap_frag(real_start, start, last, target_prot, flags, fd, offset)) { goto fail; } @@ -658,18 +659,18 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, real_start += qemu_host_page_size; } /* handle the end of the mapping */ - if (end < real_end) { - if (!mmap_frag(real_end - qemu_host_page_size, - real_end - qemu_host_page_size, end - 1, + if (last < real_last) { + abi_ulong real_page = real_last - qemu_host_page_size + 1; + if (!mmap_frag(real_page, real_page, last, target_prot, flags, fd, - offset + real_end - qemu_host_page_size - start)) { + offset + real_page - start)) { goto fail; } - real_end -= qemu_host_page_size; + real_last -= qemu_host_page_size; } /* map the middle (easier) */ - if (real_start < real_end) { + if (real_start < real_last) { void *p; off_t offset1; @@ -678,13 +679,13 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, } else { offset1 = offset + real_start - start; } - p = mmap(g2h_untagged(real_start), real_end - real_start, + p = mmap(g2h_untagged(real_start), real_last - real_start + 1, target_to_host_prot(target_prot), flags, fd, offset1); if (p == MAP_FAILED) { goto fail; } passthrough_start = real_start; - passthrough_end = real_end; + passthrough_last = real_last; } } the_end1: @@ -692,16 +693,16 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, page_flags |= PAGE_ANON; } page_flags |= PAGE_RESET; - if (passthrough_start == passthrough_end) { - page_set_flags(start, start + len - 1, page_flags); + if (passthrough_start > passthrough_last) { + page_set_flags(start, last, page_flags); } else { if (start < passthrough_start) { page_set_flags(start, passthrough_start - 1, page_flags); } - page_set_flags(passthrough_start, passthrough_end - 1, + page_set_flags(passthrough_start, passthrough_last, page_flags | PAGE_PASSTHROUGH); - if (passthrough_end < start + len) { - page_set_flags(passthrough_end, start + len - 1, page_flags); + if (passthrough_last < last) { + page_set_flags(passthrough_last + 1, last, page_flags); } } the_end: From patchwork Sun Jul 9 18:29:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700906 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4829851wrs; Sun, 9 Jul 2023 11:41:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlG0gP5MEPHrrWCX9jTHZkrla1EKMZeggPj/hqwl7J+lBmdW1/QBil2aiUrXYtBQnnU9alpv X-Received: by 2002:a05:620a:2ae1:b0:765:8986:a3bd with SMTP id bn33-20020a05620a2ae100b007658986a3bdmr9023598qkb.69.1688928108957; Sun, 09 Jul 2023 11:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688928108; cv=none; d=google.com; s=arc-20160816; b=rSe5ZFQ0HBrAejMjwExOeoOx5fjrpn1gVTAtNzabX6sb72xEYwF+yJpaOF50YdaQ5+ s8YRcbKjMRSCDfJjA2RCVu+KAXtRL3CfblgRme7bCIEvKei9lzWHpjNoBGCu8LALmShA EWH+wkJCDahh7xKwQ+fQDeNiasYcIfsC/Nl68fipcEPInn/P8I5nsQYvrMQm2TG4P0Jf paU4tcc546oTN3VqpYB8FbR5ZXTa26naMwqc4wt+O4df7bI1GBEi49Mdlo6V+Xs6wGwM jseFJvklKMhKCvFqmejH4sqMika1dAFT4MqcT7MLM8vaLf9NKl0lKuNWf2AA+zRzBMpe V6iQ== 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:cc:to :from:dkim-signature; bh=1F2YVr3IWQtmqpjJeR+MoFqCj9awn2sZVMTfzE1Dbtk=; fh=lMWaYJWKNNp5se7C5JIc/IAy1MaLsIKSBhk4MhqnayU=; b=TB4Y72awkF0tcrQVjNmy2f3gLs36MMMa2bAZwB5cpYd71McA84k8gWZQBzQZ2AzhY+ VwFtbZOaHILAGUJshyDVxHAW8sEqdSPfZrDBcXCKNyDQBm4AT8RH33Pkh75o75j4bScN aJoLpzL4H5yTx7oOpbqwsx1e3htIC7Z8TC4HfdutZjlMrLflGBnG9wcr2zzF0JlrFb7D 5g02CfGwUnZhn7UeYqVKfpmXWiMrXw/4+dm525l/moyI3cMLo8kwTxobwgTvgx2NsIPE KrwwnCRTjwew39o/AXFFRIaXXxT1QN7oZvQSE5i0hMvLiuzQeHO/hG6oQ1A00iudJTWC HaMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vv5/sAHg"; 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 b14-20020a0ccd0e000000b00636cec467casi4867811qvm.108.2023.07.09.11.41.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:41:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vv5/sAHg"; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZEG-0005aa-VU; Sun, 09 Jul 2023 14:33:52 -0400 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 1qIZEC-0004ra-Cn for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:48 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZE7-0004JE-OG for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:48 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fba8e2aa52so42044675e9.1 for ; Sun, 09 Jul 2023 11:33:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927619; x=1691519619; 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=1F2YVr3IWQtmqpjJeR+MoFqCj9awn2sZVMTfzE1Dbtk=; b=vv5/sAHgPhVuWtQjtVGI/Vqw7lnLUfVWYbTua4JNp8Rt8VQCTMJDJ3Cfvwrj5hmBG9 LeHQVGV4YWJsjs500+NlNvgaMuZY8m7nhGrqk+L9rLyy7sB3TLzPzkHD9CteKTR99sa+ wuFmOCaSSI1pwtirPQKm7akbH8L8kyG9g0fzqGq7B+Bc01GelYlawLOl1mn8Dqip+yQ4 tHX0/K7Vtov6RdQuoIkWqdrHGZM+s7PQAsfE3WbxT+I9P7bQkjPGq03JoRMNSKTP3M+m a/ShxbtmLjFcg6GwzPyaJWwZiZYIHylc7+RZ2JsmNvF+lmCEhsSh31P7W+HUNMqFEyay zOUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927619; x=1691519619; 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=1F2YVr3IWQtmqpjJeR+MoFqCj9awn2sZVMTfzE1Dbtk=; b=eaj4vb3aU+GMaFY3oj8iWDDnvPXHL2KyV8WES8SK4d3eg0mUhcT2xQIFYXEKmXdskT B3nFGDop6YMzRghvuJRd+KBf7akpWASJbptgpL9uNCkT2BjK9owww1l895332dQOy3dL Un0rAiTMYzdpmADVsCfgvT6fk3z7fPIYf5Z0oYQSnrt1h78JKlTfhTjrdiJ9EHHmBMTh rC7seT3N2S2rmXdtS9gyM8Bs/Ny4PgtV8e6UzLs7I+HCdVIGKSxz0p+Nf+G13TLVlRKz eUAjgypzr2/lKlka/E500O5OpemuYKySu4PH+dG/S0mnxPtmz2ICSp+CgjdyExHE5u+8 HrKQ== X-Gm-Message-State: ABy/qLZjDh/3UPkBMKHG8aqaxJlHC6+1d30GpLAD6KuCxskh7IUo0lJP jbhrKyroXfZR4A14kpo8MwM+nbR8lY/a71F3XOS0Pg== X-Received: by 2002:a05:600c:258:b0:3fb:c15c:698a with SMTP id 24-20020a05600c025800b003fbc15c698amr10397580wmj.4.1688927618792; Sun, 09 Jul 2023 11:33:38 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= Subject: [PULL 37/37] crypto: Unexport AES_*_rot, AES_TeN, AES_TdN Date: Sun, 9 Jul 2023 19:29:25 +0100 Message-Id: <20230709182934.309468-74-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x329.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These arrays are no longer used outside of aes.c. Acked-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/crypto/aes.h | 25 ------------------------- crypto/aes.c | 33 +++++++++++++++++++++------------ 2 files changed, 21 insertions(+), 37 deletions(-) diff --git a/include/crypto/aes.h b/include/crypto/aes.h index 99209f51b9..709d4d226b 100644 --- a/include/crypto/aes.h +++ b/include/crypto/aes.h @@ -30,29 +30,4 @@ void AES_decrypt(const unsigned char *in, unsigned char *out, extern const uint8_t AES_sbox[256]; extern const uint8_t AES_isbox[256]; -/* AES MixColumns, for use with rot32. */ -extern const uint32_t AES_mc_rot[256]; - -/* AES InvMixColumns, for use with rot32. */ -extern const uint32_t AES_imc_rot[256]; - -/* -AES_Te0[x] = S [x].[02, 01, 01, 03]; -AES_Te1[x] = S [x].[03, 02, 01, 01]; -AES_Te2[x] = S [x].[01, 03, 02, 01]; -AES_Te3[x] = S [x].[01, 01, 03, 02]; -AES_Te4[x] = S [x].[01, 01, 01, 01]; - -AES_Td0[x] = Si[x].[0e, 09, 0d, 0b]; -AES_Td1[x] = Si[x].[0b, 0e, 09, 0d]; -AES_Td2[x] = Si[x].[0d, 0b, 0e, 09]; -AES_Td3[x] = Si[x].[09, 0d, 0b, 0e]; -AES_Td4[x] = Si[x].[01, 01, 01, 01]; -*/ - -extern const uint32_t AES_Te0[256], AES_Te1[256], AES_Te2[256], - AES_Te3[256], AES_Te4[256]; -extern const uint32_t AES_Td0[256], AES_Td1[256], AES_Td2[256], - AES_Td3[256], AES_Td4[256]; - #endif diff --git a/crypto/aes.c b/crypto/aes.c index 685efbd583..836d7d5c0b 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -120,7 +120,7 @@ const uint8_t AES_isbox[256] = { /* * MixColumns lookup table, for use with rot32. */ -const uint32_t AES_mc_rot[256] = { +static const uint32_t AES_mc_rot[256] = { 0x00000000, 0x03010102, 0x06020204, 0x05030306, 0x0c040408, 0x0f05050a, 0x0a06060c, 0x0907070e, 0x18080810, 0x1b090912, 0x1e0a0a14, 0x1d0b0b16, @@ -190,7 +190,7 @@ const uint32_t AES_mc_rot[256] = { /* * Inverse MixColumns lookup table, for use with rot32. */ -const uint32_t AES_imc_rot[256] = { +static const uint32_t AES_imc_rot[256] = { 0x00000000, 0x0b0d090e, 0x161a121c, 0x1d171b12, 0x2c342438, 0x27392d36, 0x3a2e3624, 0x31233f2a, 0x58684870, 0x5365417e, 0x4e725a6c, 0x457f5362, @@ -272,7 +272,7 @@ AES_Td3[x] = Si[x].[09, 0d, 0b, 0e]; AES_Td4[x] = Si[x].[01, 01, 01, 01]; */ -const uint32_t AES_Te0[256] = { +static const uint32_t AES_Te0[256] = { 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U, 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU, @@ -338,7 +338,8 @@ const uint32_t AES_Te0[256] = { 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U, 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU, }; -const uint32_t AES_Te1[256] = { + +static const uint32_t AES_Te1[256] = { 0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU, 0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U, 0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU, @@ -404,7 +405,8 @@ const uint32_t AES_Te1[256] = { 0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU, 0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U, }; -const uint32_t AES_Te2[256] = { + +static const uint32_t AES_Te2[256] = { 0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU, 0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U, 0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU, @@ -470,8 +472,8 @@ const uint32_t AES_Te2[256] = { 0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU, 0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U, }; -const uint32_t AES_Te3[256] = { +static const uint32_t AES_Te3[256] = { 0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U, 0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U, 0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U, @@ -537,7 +539,8 @@ const uint32_t AES_Te3[256] = { 0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU, 0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU, }; -const uint32_t AES_Te4[256] = { + +static const uint32_t AES_Te4[256] = { 0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU, 0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U, 0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU, @@ -603,7 +606,8 @@ const uint32_t AES_Te4[256] = { 0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU, 0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U, }; -const uint32_t AES_Td0[256] = { + +static const uint32_t AES_Td0[256] = { 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U, @@ -669,7 +673,8 @@ const uint32_t AES_Td0[256] = { 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U, 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U, }; -const uint32_t AES_Td1[256] = { + +static const uint32_t AES_Td1[256] = { 0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU, 0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U, 0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU, @@ -735,7 +740,8 @@ const uint32_t AES_Td1[256] = { 0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U, 0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U, }; -const uint32_t AES_Td2[256] = { + +static const uint32_t AES_Td2[256] = { 0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U, 0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U, 0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U, @@ -802,7 +808,8 @@ const uint32_t AES_Td2[256] = { 0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U, 0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U, }; -const uint32_t AES_Td3[256] = { + +static const uint32_t AES_Td3[256] = { 0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU, 0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU, 0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U, @@ -868,7 +875,8 @@ const uint32_t AES_Td3[256] = { 0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U, 0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U, }; -const uint32_t AES_Td4[256] = { + +static const uint32_t AES_Td4[256] = { 0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U, 0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U, 0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU, @@ -934,6 +942,7 @@ const uint32_t AES_Td4[256] = { 0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U, 0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU, }; + static const u32 rcon[] = { 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, 0x20000000, 0x40000000, 0x80000000, From patchwork Sun Jul 9 18:29:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700904 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4829460wrs; Sun, 9 Jul 2023 11:40:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlH2WdJZXjYD0xfq+lJIbMzekOi6Xnu1zysEmtQHe0vStGMnlKD/oY3/kX1KJSTDXawk6lRt X-Received: by 2002:ac8:5b0f:0:b0:403:9abf:805c with SMTP id m15-20020ac85b0f000000b004039abf805cmr9662948qtw.40.1688928014132; Sun, 09 Jul 2023 11:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688928014; cv=none; d=google.com; s=arc-20160816; b=FhBig9CRU412lwFVOqXkkR5CEgF25mLOyVD4V5u1IiG/maQUB04tO+ggpoyxDyFajr 0bLzSnmAn0CxizJnmXiIVj01PKhnAHLsifbipD9ZtNOph/kQCjjnNJIoTT3VNJ+Pf/yV TCK3W1I5k7x/waDxOffhJn6vDC1D37tLEtnAyOzX3MC5dA1Y02PprlZhzbaEbxznLnqS xkbELxYUhaZEamltW49g1t7qei2a4OQdaU6dMLWi20WmM/moyH+o9iR7N7IYZ1Tv6zSW gm6CY00c4seP3slPssndcBTIk9aQQqwm0tBza4qYnZj8PGfXQQe6vuWqV++xA1dM0uqa 3pJg== 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:cc:to :from:dkim-signature; bh=PG65sHHMcFZxBzSd8xJSgpPdsxuZoeu52o+OB1adTRg=; fh=4nfr0hkxlMpWE4oToQ1q4rzQVecv6te3cGVRc3YFjiI=; b=Ca96b9CZ3HzcXQI6RkvraDW/TQarzhIy7QpeI6TGCarHFSIVG5sJ0g0P44cW0WksaO 7f1Q1mns36DYxxwtg/Ivdo0nLDC/H9/mqAnpgjGu9Rjz4Gk1mhGyBz6a/Vavnbu3NvLA N0nsWN6Kij7O9hgjAiI1K4pbwJWAyUnpxU2ZFmQIB024LZWlkvKdqOKSlUmTI7aV+Wyy y/pwIc3HiDCzndpJlfjOvk0EuoJ9Z8+XyrzmiRCGfg6xH4KIRTzyRJTJc8yuryxmg/Mf LtwnJjF1de/Qbklw9NgPC1Tpkf1IukLCUPkTPslvt3hCWMJCZDo6TBrDYHojahlgpcmV PKGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bWpCwr6o; 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 u4-20020ac858c4000000b00403acdbb3a8si529705qta.669.2023.07.09.11.40.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:40:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bWpCwr6o; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZEN-0005q9-3g; Sun, 09 Jul 2023 14:33:59 -0400 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 1qIZEA-0004ef-S7 for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:46 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZE7-0004Ji-QD for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:46 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fbc59de0e2so39224275e9.3 for ; Sun, 09 Jul 2023 11:33:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927620; x=1691519620; 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=PG65sHHMcFZxBzSd8xJSgpPdsxuZoeu52o+OB1adTRg=; b=bWpCwr6oIeaRCR3Ljp5v3nPuvlCaD/jzUjNqgX71QHYBMq46PU2JuphL67Oz9eG+vH zVpSM3rAzArFaDZ9m+94SIgvLZS/YQYvBDOjfSzgpktizCpRmrCddd3eQUwensory+MN lFAza014Hzc1tnmVfQyrSM4Kd6tcI8e9zv2bNd/x91JIkl7XCuxXlkwGCvaAPxa98EDb Ag5/PbjIev+XMH7tsvC1WIXZuwLqJq5+cGfx9BOgWKI4FV18eCpQ5/6BaDeWXZau26jh +qGf0qmFOsaQZq435z7EC5yWjX8xWmjt8wyr/EF51Gvva6pgifU7g1nhIKsR9G+U+QIG q/BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927620; x=1691519620; 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=PG65sHHMcFZxBzSd8xJSgpPdsxuZoeu52o+OB1adTRg=; b=fdFOQVCb9fHzpc+P6bjM0QLvtVllJxNdRa0hT5cjfbNpPHjc8zldBGpbiwNqLrRzcF +/lf+ggE/+GkKBMh4eEwUSdNm2jIFcqpR89j+be+yC7UbF0I+gvcnyeNNgCSlmpBS+La u4DVjDQICSzTQq9r2Pbw+5GIbR5gofg1WCqlJKQg0JzNuxkFYs4UifwmlakVBXjyQeBf GWCE8sgvHMemfXQFPHKyvt+ll0hkaMPfS6c9fPAS2wntR8n7A3PrcJIMOoGvDmd1LJel M6XCb3i0THPFSUVGIJZ/9IOFPNVchKx6Cw7sbPe3fiwsWgmq0Idra93aHTZjJsCb0A8M 39UQ== X-Gm-Message-State: ABy/qLYtN47WXKm57nbg3jh9b0N7vw/92CLLQ3xYrrxfaLrI+QkoI8MS 015oktLccEXzGowiLiWOzR/C9CPwDGXXll048V1Pmg== X-Received: by 2002:a1c:7416:0:b0:3fc:27:7e46 with SMTP id p22-20020a1c7416000000b003fc00277e46mr6260858wmc.3.1688927620257; Sun, 09 Jul 2023 11:33:40 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH 38/45] linux-user: Rename mmap_reserve to mmap_reserve_or_unmap Date: Sun, 9 Jul 2023 19:29:27 +0100 Message-Id: <20230709182934.309468-76-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x335.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org If !reserved_va, munmap instead and assert success. Update all callers. Signed-off-by: Richard Henderson Message-Id: <20230707204054.8792-22-richard.henderson@linaro.org> --- linux-user/mmap.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 6308787942..22c2869be8 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -722,14 +722,14 @@ fail: return -1; } -static void mmap_reserve(abi_ulong start, abi_ulong len) +static void mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) { abi_ulong real_start; abi_ulong real_last; abi_ulong real_len; abi_ulong last; abi_ulong a; - void *host_start, *ptr; + void *host_start; int prot; last = start + len - 1; @@ -776,9 +776,15 @@ static void mmap_reserve(abi_ulong start, abi_ulong len) real_len = real_last - real_start + 1; host_start = g2h_untagged(real_start); - ptr = mmap(host_start, real_len, PROT_NONE, - MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE, -1, 0); - assert(ptr == host_start); + if (reserved_va) { + void *ptr = mmap(host_start, real_len, PROT_NONE, + MAP_FIXED | MAP_ANONYMOUS + | MAP_PRIVATE | MAP_NORESERVE, -1, 0); + assert(ptr == host_start); + } else { + int ret = munmap(host_start, real_len); + assert(ret == 0); + } } int target_munmap(abi_ulong start, abi_ulong len) @@ -830,11 +836,7 @@ int target_munmap(abi_ulong start, abi_ulong len) ret = 0; /* unmap what we can */ if (real_start < real_end) { - if (reserved_va) { - mmap_reserve(real_start, real_end - real_start); - } else { - ret = munmap(g2h_untagged(real_start), real_end - real_start); - } + mmap_reserve_or_unmap(real_start, real_end - real_start); } if (ret == 0) { @@ -871,7 +873,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, * If new and old addresses overlap then the above mremap will * already have failed with EINVAL. */ - mmap_reserve(old_addr, old_size); + mmap_reserve_or_unmap(old_addr, old_size); } } else if (flags & MREMAP_MAYMOVE) { abi_ulong mmap_start; @@ -886,7 +888,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, flags | MREMAP_FIXED, g2h_untagged(mmap_start)); if (reserved_va) { - mmap_reserve(old_addr, old_size); + mmap_reserve_or_unmap(old_addr, old_size); } } } else { @@ -912,7 +914,8 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, errno = ENOMEM; host_addr = MAP_FAILED; } else if (reserved_va && old_size > new_size) { - mmap_reserve(old_addr + old_size, old_size - new_size); + mmap_reserve_or_unmap(old_addr + old_size, + old_size - new_size); } } } else { From patchwork Sun Jul 9 18:29:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700928 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4830538wrs; Sun, 9 Jul 2023 11:44:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlGtO/KfqyDjN/A2m18sPv+WcSv83C/Ys2DDlIzQTqarSjpTTUzztorE0uGJ3sa7fV/fGyBD X-Received: by 2002:a05:6214:29e7:b0:637:2eb:6c23 with SMTP id jv7-20020a05621429e700b0063702eb6c23mr16426554qvb.18.1688928271234; Sun, 09 Jul 2023 11:44:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688928271; cv=none; d=google.com; s=arc-20160816; b=g4QJajdJWdbcFOI9nG52nx81XpZjFYheHHeGy7fTZFd0W2A6Bss4oAPvqhc600KGwf tU/iabFDIYLvf1PQBxPSCT51fft01ZYAoeSmu3HAvFJrWJTS8LGJTqi07BF1mokJ7y7q 6kNwifnSN1Ejv3pnMvl5whybn8t44EZTtEndVzV61Xvpiszp51AyvzCcNng6xHiPDbwQ g2lcN8GRpc3fYuZhlfseekp7hibvKOUWcRzuzxlt6jA4BnD+0rRfFbCZXsysRnzsLMD1 MEpRHFnEW/LUQlgBOM8dg/9rnNnqdOkEEW7iZkIYwga6xJZswgE6j/5GqiBy1VColJ3X wr0A== 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:cc:to :from:dkim-signature; bh=t83L6VQqehKor298fA996V/rrvqxT+XEe+3FbTWkw4k=; fh=4nfr0hkxlMpWE4oToQ1q4rzQVecv6te3cGVRc3YFjiI=; b=xpD4h4OPn0YvPhxn6z1g05tKMjvWWbJ792XfKmWwXfykunrgD3qH+1l4bksliH4RqB ttZhog2/p0UUA8TQo7pF/GiV5rYnovG2D8g9mGKNgngTlajeHXOKpYDjrh54btfgMZXK vOqZxJbTkuuyuGv/NeMCdrdBqbP0XYhJrsgrX8HiEMPu1LZosGMrz6tZnIMXnXRSx607 WO5kYzWYd1dHYqZPO4Jpm2Ea5c3O/15rafS9TlWB1ZQIdQZknICg2TvJPRkd5vakzlWZ 9AV4S4/MM6qJBPk2as5LpGIbx8B8kLy5pg6a8Uv96zgctuJ+xB+XIqysWIA+SjqeQBh6 L4YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kQaUVUPQ; 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 z17-20020a0cda91000000b0063787a7bfc1si4831775qvj.143.2023.07.09.11.44.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:44:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kQaUVUPQ; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZEM-0005pY-B6; Sun, 09 Jul 2023 14:33:58 -0400 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 1qIZEA-0004ea-Ru for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:46 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZE7-0004Jn-Qb for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:46 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3fc0aecf107so8739125e9.2 for ; Sun, 09 Jul 2023 11:33:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927621; x=1691519621; 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=t83L6VQqehKor298fA996V/rrvqxT+XEe+3FbTWkw4k=; b=kQaUVUPQHaIfuWMdM6KPEnpd41H8weDogiYdg+ahuQs3fuP763VCmoofEAwrGNDZgU ClaVUgb7o3nX8Wq6TyTLefd68wl3OMFnhGtaX6OakKTb/BEgXjf2DzYr2s5wrcDbl5Ef KsrY7ehB00eBo2Waagk7yWeRBdi7X0824QYRBNh2iAGTxschPplO3hrvTFupOy6tVYeq uRwPBWQ1Tg1AwahAycLribuuWRmWI08vXyggTExjL8YmSH9VsZxBS5HW/+RHpktQRtT0 Y4znok1w5Sl/ssuGasaIX04B2lurqO55J9RTupe523r8LAPilc31F0lsUF+bsnRrIbdf c0pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927621; x=1691519621; 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=t83L6VQqehKor298fA996V/rrvqxT+XEe+3FbTWkw4k=; b=V44QD8Fskcdkl0jLKHgIOPvCe0wsSyAsqTh+0POv1WA0Cju1lFVVD36Wy6DU77PeQd QKAckZb4sgHM5fC/osATRSH6ojIW1N/lk85gbCCO/L+sVpcqy7xLbg7e60v20E20RHF6 2xOSemy71cIxljU9kJ1K5/xCDo9NL9Yi/dfNBJc6GInMPIJ9YPmzvxsni69v5KwLTxhl CiKzXF6hhTqtWc/pFn7dl/lxvq+xCsPO8n744GtlV8rURO6Cd+91cFTiV5rtdQM+skUn 5zW2AMNmxgSr3G/eiM9Lr+O9lDhfZ/ewANrIAvUxt1s9GvaMOQOhu5hvO8VunhERgija C5NA== X-Gm-Message-State: ABy/qLYOr/bq7XnOC7jg2IvTC49STE+HpX/IwVT2pSVpMMPw5nhj0T1n p/vMxHVSFlJtdFyamRwR2ObJpGrrSM0IliECvd45zg== X-Received: by 2002:a7b:c8cd:0:b0:3fc:5d2:1f47 with SMTP id f13-20020a7bc8cd000000b003fc05d21f47mr3988040wml.20.1688927620957; Sun, 09 Jul 2023 11:33:40 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH 39/45] linux-user: Simplify target_munmap Date: Sun, 9 Jul 2023 19:29:28 +0100 Message-Id: <20230709182934.309468-77-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x332.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org All of the guest to host page adjustment is handled by mmap_reserve_or_unmap; there is no need to duplicate that. There are no failure modes for munmap after alignment and guest address range have been validated. Signed-off-by: Richard Henderson Message-Id: <20230707204054.8792-23-richard.henderson@linaro.org> --- linux-user/mmap.c | 47 ++++------------------------------------------- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 22c2869be8..c0946322fb 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -789,9 +789,6 @@ static void mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) int target_munmap(abi_ulong start, abi_ulong len) { - abi_ulong end, real_start, real_end, addr; - int prot, ret; - trace_target_munmap(start, len); if (start & ~TARGET_PAGE_MASK) { @@ -803,47 +800,11 @@ int target_munmap(abi_ulong start, abi_ulong len) } mmap_lock(); - end = start + len; - real_start = start & qemu_host_page_mask; - real_end = HOST_PAGE_ALIGN(end); - - if (start > real_start) { - /* handle host page containing start */ - prot = 0; - for (addr = real_start; addr < start; addr += TARGET_PAGE_SIZE) { - prot |= page_get_flags(addr); - } - if (real_end == real_start + qemu_host_page_size) { - for (addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) { - prot |= page_get_flags(addr); - } - end = real_end; - } - if (prot != 0) { - real_start += qemu_host_page_size; - } - } - if (end < real_end) { - prot = 0; - for (addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) { - prot |= page_get_flags(addr); - } - if (prot != 0) { - real_end -= qemu_host_page_size; - } - } - - ret = 0; - /* unmap what we can */ - if (real_start < real_end) { - mmap_reserve_or_unmap(real_start, real_end - real_start); - } - - if (ret == 0) { - page_set_flags(start, start + len - 1, 0); - } + mmap_reserve_or_unmap(start, len); + page_set_flags(start, start + len - 1, 0); mmap_unlock(); - return ret; + + return 0; } abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, From patchwork Sun Jul 9 18:29:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700919 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4830241wrs; Sun, 9 Jul 2023 11:43:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlFoN1zRtkq4y4lyewLWVd9cIEh40MEKiHE9ZkRHUTctCuncKneDDt/pNP7X5NcJHSSbqn0I X-Received: by 2002:a05:622a:155:b0:403:73bd:dd42 with SMTP id v21-20020a05622a015500b0040373bddd42mr14092593qtw.26.1688928197223; Sun, 09 Jul 2023 11:43:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688928197; cv=none; d=google.com; s=arc-20160816; b=0RjaEr+93YPtSb8XkETEduzh7+isAp5eVVNuqU65U7Hn3Em7mSMmCSiLtBY7EmGsHS PlX34Y1f2e5lHxyRYI0opJXQ8tv+wlJVEiFY6T7sHuEp0NR/U0u2CdhFPsv/+U3TGk09 iu92ces+zxEVcpliaN5wg/ElyL/9dMljkxwUo+JTZpt8eEbeH0meOeSjSl+zKNhXiTr2 SpJKFT57pRbFTjba+yZMFYqBFhBs7DNMTcRNpWSjzH/TH1Mm0536PdJy+l/FPOCxwmj6 1x5B5DoDLoJyevvVPEwpRH1/HAdjNjhl/OaweyNGwn6FS96kVN3W7OH+4p01b1aYjo7p +WBw== 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:cc:to :from:dkim-signature; bh=+u+6sqOJ5iK1/8L4kug7OWcFShgptBBIOzAjdLQUcYU=; fh=3IEiF/YPZ00TE94rna3Orj/L+TRFhpuNf7ElRJz3ubE=; b=eOZbmZ0i/DiIsRvYnwb8xHSAALpnEhmODDroYHMEmtyHAXWIl62jZwj8XN9j6pdE4m 1Kqoo6xwAVbj2Rxi+zdq8xA5TEqRmoXVHjMep5ASHYWH54nQQMZBWUnbN7jXR+3dakV0 YAmPla7liBvoBZNjXpTQUwinKtF4R++fwrAXXEl1d7dsexxXm4KFEbrCJoV2zuqQlrg+ FM5Ado05/oa4sTMcFF5r86Ok83EhGS8ciq07dHKbJ4GpBGXRhjBk3G7AbV/yRWVYIVh+ ws7o1R4pWur7qQSceUxvQvgJ7zXBl59g9b65177tve5eNDAHthLha/Tg6Apw/431EuMi oNgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YH4bzitB; 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 d19-20020a05622a15d300b00403a04b7ae2si2530973qty.428.2023.07.09.11.43.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:43:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YH4bzitB; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZEE-0005BQ-CD; Sun, 09 Jul 2023 14:33:50 -0400 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 1qIZE9-0004QN-9L for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:45 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZE7-0004Js-Pm for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:44 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fbca8935bfso37967655e9.3 for ; Sun, 09 Jul 2023 11:33:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927622; x=1691519622; 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=+u+6sqOJ5iK1/8L4kug7OWcFShgptBBIOzAjdLQUcYU=; b=YH4bzitB7tbGEyrhunznqzVxTiIaWzTjoUq5WxnikLyFHp5Nihcv1GTLxBpptbXvWN mSG5fo6M1eUpbrm0xqoj8cMxGbLH9INnHzdZKB0ZrGxDoTDlHbkuG3uEQcCxMrR8ZVV8 +Cgr2eOzqA9V2O0FSMub7ZSsmz08L3d3ZlSz5vp5Ca3JOZ4qrwmfYSQSZEkPPtz1ahgC pGhj4jMdgkwxAB9I864M3Y/iqfIp9hrCeYrh4EGQjiyPhEjDAlwhwtvtzpdniqh6RrnM vvnmTmtZ9e+anvfi4FUs5JRInnZ17Yibpl6tuD8s02/9pR9gfu947i6bkmNo9gNQfHU+ drMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927622; x=1691519622; 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=+u+6sqOJ5iK1/8L4kug7OWcFShgptBBIOzAjdLQUcYU=; b=gxjkZ0yVX+qBntNakuagerZmeC+WJxO+HWZH7uNq8v3IRv+250c2YbOJMy8UudC8s/ wv6A+fUmE+lTbkdeB1zoA+CX64RLWxF3/UAlGbWg3XOyWexOJU93H+0anQV1MsePfI5r K/u2sih0hGHRhqvwC0BQpzLfeLJbd1oLUFRTeDdTqzp4hPdxnhrtiIp/0jgdHTia4wc4 +uAm1CTVJSdOBGzNOhbNYozfrr4n3z7N+Xczjdbyhwn0wu0nKIiGTGpFF6Pn+ZO2+DWG gSH+vTrhFqcnxQHxIcEVUd5II74/7bFC7cnO+pPzQneVmgU2OerY40hYr4nO49DS1Y7k y29A== X-Gm-Message-State: ABy/qLZU1jCbNsYzHPa1xoQNCkqgXuuR6eBNv8+lvskPFBvqeDNGUIS4 b9Wlx5rGFo+JxhN8+JPL9oRagtLtXiCVJLfS0aNQjA== X-Received: by 2002:a5d:4809:0:b0:314:3ad6:2327 with SMTP id l9-20020a5d4809000000b003143ad62327mr7584486wrq.12.1688927621850; Sun, 09 Jul 2023 11:33:41 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 40/45] accel/tcg: Accept more page flags in page_check_range Date: Sun, 9 Jul 2023 19:29:29 +0100 Message-Id: <20230709182934.309468-78-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32f.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Only PAGE_WRITE needs special attention, all others can be handled as we do for PAGE_READ. Adjust the mask. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230707204054.8792-24-richard.henderson@linaro.org> --- accel/tcg/user-exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index e4f9563730..1e8fcaf6b0 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -561,8 +561,8 @@ int page_check_range(target_ulong start, target_ulong len, int flags) } missing = flags & ~p->flags; - if (missing & PAGE_READ) { - ret = -1; /* page not readable */ + if (missing & ~PAGE_WRITE) { + ret = -1; /* page doesn't match */ break; } if (missing & PAGE_WRITE) { From patchwork Sun Jul 9 18:29:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700894 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4829130wrs; Sun, 9 Jul 2023 11:38:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlHD6OSPCny/bpnXI/qKijb6jCk/yDVfo7eP4JIrHppFySuwcIyBm5jFQJ+WYG8oHvtfZN6x X-Received: by 2002:a05:622a:1653:b0:400:9c4e:2abe with SMTP id y19-20020a05622a165300b004009c4e2abemr12978402qtj.13.1688927929574; Sun, 09 Jul 2023 11:38:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927929; cv=none; d=google.com; s=arc-20160816; b=O1qTgWCH0+zDkHIOnpK9GBtnD1tHGJm9lVqw1olJ0elGCGDV46GWR2vhm5aKV316rM XZv8b6a5U4dBlbWyZw3lDA6E6jlc3ZC1YRN89RxV5bvxWbwcfSKysN3VGZZtj34Tl6z8 T+gByGznD/zYPuCJRDFkNBbrHw6zhpmiwO0EqePEPY3aumeUjY+wI4EyqkBWxFC8xFYh VQC8Kw1aNw77/Iy4W4TCCFEokJflbEWtTurbPFSsg6SOoMUivy8s++1R/Caai661hClG eM6HwfA3S8289dCFnyyxBxrzo5bcN135LH3Ze7qsyMB4twucGIfClIhJNAd/S2Jgj0pY aMCQ== 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:cc:to :from:dkim-signature; bh=oeaMN26iaa0LPgHmrLDUb1dwvxX1dVRVMAoE87lDllw=; fh=4nfr0hkxlMpWE4oToQ1q4rzQVecv6te3cGVRc3YFjiI=; b=nDhEsEDoA3ITlPUOmQIGAry43gAquwWUf9A0sayqzN6tSWDVdKzK5TPUaYQfZjZcTK vrn8gmy8vW+9mqVJyWklUohjEHZh9VmOUUUFIbdUAMt7B9ABbUQQOLP7q0qm0n/AH5Cx wjOJ7EcH+ynXHUIeb/hhdvQNf7Q+HhbKHntdtLocCyqDOokQf34rZtD8mlIcKbSnT6vr BElKRNpUlHA2qgtohS+zt0GLWeScrl2bhWXDN1XhrKAwEoL3I4YkYfWwW3wIGcaSqzh+ VcoikchRBuWNj+YMYqSmifpxsejSKKsbCI6VO09lL8YiWhSHYO2k+Ya3v4W6D21JX0pk 4EmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="d/4vCl7K"; 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 o19-20020a05622a139300b004039edfc60csi2618560qtk.182.2023.07.09.11.38.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:38:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="d/4vCl7K"; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZEN-0005q5-1Y; Sun, 09 Jul 2023 14:33:59 -0400 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 1qIZEC-0004uJ-Jg for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:48 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZE8-0004Jz-RX for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:48 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3fbf7fbe722so43531365e9.3 for ; Sun, 09 Jul 2023 11:33:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927622; x=1691519622; 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=oeaMN26iaa0LPgHmrLDUb1dwvxX1dVRVMAoE87lDllw=; b=d/4vCl7Knanzf6o+OPCn04YJWYaCWORWATUv54RhvszQ3C5TA/qIsJZimT9K2L++rg S7np8jaJmGb6U+Qfci7dvAKznisPiBmE4JUTE/B9bFM6snOulg7RrMWB9ESaWZWHbF8X YOC/+fm6Lh0RFmtRu0sjWAkjpWcDKjy9HoCjxS9Y3Yj59pBZp3RfOb6cqurycnFw2iJ7 3vzVmCWP72Au6hlcxHa0sdtliD/7qQgZWXMB8f2CLdByJTgGzqXEY+ZIbW6cPulZvcWK rCTLxKPsuvJBpFpXBck05XnnlzW6C0NfhMENIb30gjWi1i0bxpWEmtw/Uv9d037yWX/7 WmKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927622; x=1691519622; 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=oeaMN26iaa0LPgHmrLDUb1dwvxX1dVRVMAoE87lDllw=; b=YRyaQD3dNM4Wo5u2NmiqlOeNdoX+mpvP2knwMsTjQbZw3tNaohMXh2xHPpP251mkQo jzkV21BHFLvfQwdPuE3P787zWdAYjNuCGL/9OUX/5kQyOXFjxEjSdtiBHcND58V528mX KwubcN3KVSG4h9w3CLOTLmDVwJiVVsI/GI+FSnxE+TDa1tKYFSgjBkiEv5l4D7Uy+XHO HxrNBjNsranH2zwBHFBVzTumSKifoSu4RWV5udCZ8G8cgTDbs2a2RIoqs/v6QfMZ3FQV aKdbms6tBKT2QzWW5OfXc3V9EL7wICONHsNpZnd5+K/9JXoTXqiEcTezPrRUvJLTmsXq FjWw== X-Gm-Message-State: ABy/qLZz8ExEF//re8nnZtkCdWaovReAQ3iFiHVonHlapfE/9LH7EkqV FYLcjKFStBn59ItgVAlBgweUjLrJtSOBZHc2iCk/ew== X-Received: by 2002:adf:ee0c:0:b0:314:3997:530d with SMTP id y12-20020adfee0c000000b003143997530dmr13042027wrn.31.1688927622564; Sun, 09 Jul 2023 11:33:42 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH 41/45] accel/tcg: Return bool from page_check_range Date: Sun, 9 Jul 2023 19:29:30 +0100 Message-Id: <20230709182934.309468-79-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32d.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Replace the 0/-1 result with true/false. Invert the sense of the test of all callers. Document the function. Signed-off-by: Richard Henderson Message-Id: <20230707204054.8792-25-richard.henderson@linaro.org> --- bsd-user/qemu.h | 2 +- include/exec/cpu-all.h | 13 ++++++++++++- linux-user/qemu.h | 2 +- accel/tcg/user-exec.c | 22 +++++++++++----------- linux-user/syscall.c | 2 +- target/hppa/op_helper.c | 2 +- target/riscv/vector_helper.c | 2 +- target/sparc/ldst_helper.c | 2 +- accel/tcg/ldst_atomicity.c.inc | 4 ++-- 9 files changed, 31 insertions(+), 20 deletions(-) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 41d84e0b81..edf9602f9b 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -267,7 +267,7 @@ abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2); static inline bool access_ok(int type, abi_ulong addr, abi_ulong size) { - return page_check_range((target_ulong)addr, size, type) == 0; + return page_check_range((target_ulong)addr, size, type); } /* diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index eb1c54701a..94f44f1f59 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -222,7 +222,18 @@ int walk_memory_regions(void *, walk_memory_regions_fn); int page_get_flags(target_ulong address); void page_set_flags(target_ulong start, target_ulong last, int flags); void page_reset_target_data(target_ulong start, target_ulong last); -int page_check_range(target_ulong start, target_ulong len, int flags); + +/** + * page_check_range + * @start: first byte of range + * @len: length of range + * @flags: flags required for each page + * + * Return true if every page in [@start, @start+@len) has @flags set. + * Return false if any page is unmapped. Thus testing flags == 0 is + * equivalent to testing for flags == PAGE_VALID. + */ +bool page_check_range(target_ulong start, target_ulong last, int flags); /** * page_check_range_empty: diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 9b8e0860d7..802794db63 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -182,7 +182,7 @@ static inline bool access_ok_untagged(int type, abi_ulong addr, abi_ulong size) : !guest_range_valid_untagged(addr, size)) { return false; } - return page_check_range((target_ulong)addr, size, type) == 0; + return page_check_range((target_ulong)addr, size, type); } static inline bool access_ok(CPUState *cpu, int type, diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 1e8fcaf6b0..df60c7d673 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -520,19 +520,19 @@ void page_set_flags(target_ulong start, target_ulong last, int flags) } } -int page_check_range(target_ulong start, target_ulong len, int flags) +bool page_check_range(target_ulong start, target_ulong len, int flags) { target_ulong last; int locked; /* tri-state: =0: unlocked, +1: global, -1: local */ - int ret; + bool ret; if (len == 0) { - return 0; /* trivial length */ + return true; /* trivial length */ } last = start + len - 1; if (last < start) { - return -1; /* wrap around */ + return false; /* wrap around */ } locked = have_mmap_lock(); @@ -551,33 +551,33 @@ int page_check_range(target_ulong start, target_ulong len, int flags) p = pageflags_find(start, last); } if (!p) { - ret = -1; /* entire region invalid */ + ret = false; /* entire region invalid */ break; } } if (start < p->itree.start) { - ret = -1; /* initial bytes invalid */ + ret = false; /* initial bytes invalid */ break; } missing = flags & ~p->flags; if (missing & ~PAGE_WRITE) { - ret = -1; /* page doesn't match */ + ret = false; /* page doesn't match */ break; } if (missing & PAGE_WRITE) { if (!(p->flags & PAGE_WRITE_ORG)) { - ret = -1; /* page not writable */ + ret = false; /* page not writable */ break; } /* Asking about writable, but has been protected: undo. */ if (!page_unprotect(start, 0)) { - ret = -1; + ret = false; break; } /* TODO: page_unprotect should take a range, not a single page. */ if (last - start < TARGET_PAGE_SIZE) { - ret = 0; /* ok */ + ret = true; /* ok */ break; } start += TARGET_PAGE_SIZE; @@ -585,7 +585,7 @@ int page_check_range(target_ulong start, target_ulong len, int flags) } if (last <= p->itree.last) { - ret = 0; /* ok */ + ret = true; /* ok */ break; } start = p->itree.last + 1; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8a5a82fcec..5870eb84e5 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8108,7 +8108,7 @@ static int open_self_maps_1(CPUArchState *cpu_env, int fd, bool smaps) max = h2g_valid(max - 1) ? max : (uintptr_t) g2h_untagged(GUEST_ADDR_MAX) + 1; - if (page_check_range(h2g(min), max - min, flags) == -1) { + if (!page_check_range(h2g(min), max - min, flags)) { continue; } diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index 32c27c66b2..f25a5a72aa 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -168,7 +168,7 @@ target_ureg HELPER(probe)(CPUHPPAState *env, target_ulong addr, uint32_t level, uint32_t want) { #ifdef CONFIG_USER_ONLY - return (page_check_range(addr, 1, want) == 0) ? 1 : 0; + return page_check_range(addr, 1, want); #else int prot, excp; hwaddr phys; diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c index 1e06e7447c..1f9549f168 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -583,7 +583,7 @@ vext_ldff(void *vd, void *v0, target_ulong base, cpu_mmu_index(env, false)); if (host) { #ifdef CONFIG_USER_ONLY - if (page_check_range(addr, offset, PAGE_READ) < 0) { + if (page_check_range(addr, offset, PAGE_READ)) { vl = i; goto ProbeSuccess; } diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c index 981a47d8bb..78b03308ae 100644 --- a/target/sparc/ldst_helper.c +++ b/target/sparc/ldst_helper.c @@ -1191,7 +1191,7 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, case ASI_PNFL: /* Primary no-fault LE */ case ASI_SNF: /* Secondary no-fault */ case ASI_SNFL: /* Secondary no-fault LE */ - if (page_check_range(addr, size, PAGE_READ) == -1) { + if (!page_check_range(addr, size, PAGE_READ)) { ret = 0; break; } diff --git a/accel/tcg/ldst_atomicity.c.inc b/accel/tcg/ldst_atomicity.c.inc index de70531a7a..4de0a80492 100644 --- a/accel/tcg/ldst_atomicity.c.inc +++ b/accel/tcg/ldst_atomicity.c.inc @@ -159,7 +159,7 @@ static uint64_t load_atomic8_or_exit(CPUArchState *env, uintptr_t ra, void *pv) * another process, because the fallback start_exclusive solution * provides no protection across processes. */ - if (!page_check_range(h2g(pv), 8, PAGE_WRITE_ORG)) { + if (page_check_range(h2g(pv), 8, PAGE_WRITE_ORG)) { uint64_t *p = __builtin_assume_aligned(pv, 8); return *p; } @@ -194,7 +194,7 @@ static Int128 load_atomic16_or_exit(CPUArchState *env, uintptr_t ra, void *pv) * another process, because the fallback start_exclusive solution * provides no protection across processes. */ - if (!page_check_range(h2g(p), 16, PAGE_WRITE_ORG)) { + if (page_check_range(h2g(p), 16, PAGE_WRITE_ORG)) { return *p; } #endif From patchwork Sun Jul 9 18:29:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700880 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4828390wrs; Sun, 9 Jul 2023 11:35:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlG3L2XT5tl6j+EQzEfYrBxaZ6Vf0FSTqkIF+hor3FnzCJat2LPeqDfM4bO8IhgnDC+b2OUH X-Received: by 2002:a05:620a:4611:b0:767:494f:4ab5 with SMTP id br17-20020a05620a461100b00767494f4ab5mr11762951qkb.39.1688927737435; Sun, 09 Jul 2023 11:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927737; cv=none; d=google.com; s=arc-20160816; b=QhXhX02Lj8MQXqmGoKMA2zqlu/OUI2AxjmFXKGQK4di446j0bZeakVZSItFzIIaMOe scnnuIR0F0D+62yUUe4Uka9oQqlGnakaqPxmDc5HMuwf9dtQb0JSgERFt4g0yHGd3yIi VUaxiv+wFS08QDq7zQW4wQC6aaZGmiF16Hv1rV8+mc+gZzzOMswQ2AcGiC1q7uH7JruG Q8xVc9NDLp77xihZVz84Y4CeyYVeE9d7vhk3lACk+QmsDeCE5poa5u4mto6FzX0izaAF H5xHjT/TVldjmiO4Azj+MBmw/xcIwEg03jyDvh2vnpK1TpvYd4D0A5Y8NqrexOSspFrw 4lYA== 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:cc:to :from:dkim-signature; bh=ZRHsYp/A8D0Uk3Tfg/o0B0POYY0J/63KdYiHo0geXzY=; fh=4nfr0hkxlMpWE4oToQ1q4rzQVecv6te3cGVRc3YFjiI=; b=mbBwN3cWtrqEcFkmv8BfNoX+/gOYJoFEu2e5wDtsOD4TKiEhFhmuZjuu1wPKb6babL THiuV0prSt34BdgoTPU3zVAk3eb0uJiz/TCMSccMdJ9S5sg+gIzxmbMiryweBgm9/xN9 Equ6TuGxCi+2xJRYC+NpBQWnbHEliLIbzOLQehu4VxVcWTymw5Vx4SKBMmPkYKU+tC9p AW3l3ErQm1dJ1AclyYgte4/nBmta0qVakhTXnuq3sbJjIR1dqOjmErZna6+HVKFbXUq6 ynzQr+TQKZwLQ4O9HPnPw+gQnm05PIZHOpFnU4nFFm3UBzjjV+xOMcTA6iCHr8LgL77w oFYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mMoCMklI; 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 d26-20020a05620a137a00b0076541ed7f95si4778561qkl.9.2023.07.09.11.35.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:35:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mMoCMklI; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZEG-0005TN-7z; Sun, 09 Jul 2023 14:33:52 -0400 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 1qIZEA-0004eg-Sd for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:46 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZE8-0004K5-KE for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:33:46 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-307d20548adso3709569f8f.0 for ; Sun, 09 Jul 2023 11:33:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927623; x=1691519623; 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=ZRHsYp/A8D0Uk3Tfg/o0B0POYY0J/63KdYiHo0geXzY=; b=mMoCMklIrOEVeo9gSyyjnpyAee6Tn3Zwd9lMS9f0NVqSbhQDLo1leNcYaVy7ES37TE nPFQBH4wuDkHZYxvdqd0SBNj6p0UdH3PMc9yZpnK5iLY+pRnzOYxlqXrJwyrBgiPjmmE u+f/CxM4aqDoL/CpjNbiBgP/R20At12TaKz6etgSGb5XaHwWU3bSx/oJJWH29NmElfvU nfp9j/J1E1PZXS5kzjl8cYiRg8xh1bRwqUmTxllDd3h3DxukZSIO0i6auuhvtPw3FYso QVB110MhdNSafXl9Q8/ghLixOfjO6MGimStFCZwGxiqihZvZiaBfLFCLpg20GK+vBZb3 UQAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927623; x=1691519623; 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=ZRHsYp/A8D0Uk3Tfg/o0B0POYY0J/63KdYiHo0geXzY=; b=l8E5NL4S/vnxF98Bg0sEURmqp/gSd5QHfm4WaZ+qYLQ3M+OWlq4fFAKV5RJy4mS6Nd gz5kevU8/TJyO4xjXDExad5DZ2QbnlAW1B+GDT8zrOGK38fSwDg1Mfu7XIlMMgm3YdGr 89L5Sp8LvfUXbvwiBjorJV3O0wIPsJGilsUtwso5otX7ZozP6qX8nNTD0z9Upvibnd0+ UDxm2HjjyqP2xF6xLLGllFEK2Y7IM8Tt+xiCVAOSHS2gVhmP1QFTVZ3Yp5tKn8IEe/hl D8GYcbb9MwJ0yQu24hQuq/FH9nvoNiCPX/A2j7DRa8UMK1OBv3vN3Ap3baRKayJYzsjC ryfg== X-Gm-Message-State: ABy/qLaQ9aFKxlJhvivmnEBAZiArkeKnLZYjTTJt7nXe/B2XqLH+pS76 OrD6/QHm/4lFW7Sy4PSFpES+0cik5BCi5Q3SEkyvhg== X-Received: by 2002:a5d:5109:0:b0:314:dc0:73f1 with SMTP id s9-20020a5d5109000000b003140dc073f1mr8442169wrt.38.1688927623387; Sun, 09 Jul 2023 11:33:43 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id e17-20020a5d4e91000000b0031433760a92sm9635256wru.115.2023.07.09.11.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:33:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH 42/45] linux-user: Remove can_passthrough_madvise Date: Sun, 9 Jul 2023 19:29:31 +0100 Message-Id: <20230709182934.309468-80-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42e.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use page_check_range instead, which uses the interval tree instead of checking each page individually. Signed-off-by: Richard Henderson Message-Id: <20230707204054.8792-26-richard.henderson@linaro.org> --- linux-user/mmap.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index c0946322fb..49cfa873e0 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -898,23 +898,6 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, return new_addr; } -static bool can_passthrough_madvise(abi_ulong start, abi_ulong end) -{ - ulong addr; - - if ((start | end) & ~qemu_host_page_mask) { - return false; - } - - for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { - if (!(page_get_flags(addr) & PAGE_PASSTHROUGH)) { - return false; - } - } - - return true; -} - abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice) { abi_ulong len, end; @@ -964,9 +947,8 @@ abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice) * * A straight passthrough for those may not be safe because qemu sometimes * turns private file-backed mappings into anonymous mappings. - * can_passthrough_madvise() helps to check if a passthrough is possible by - * comparing mappings that are known to have the same semantics in the host - * and the guest. In this case passthrough is safe. + * If all guest pages have PAGE_PASSTHROUGH set, mappings have the + * same semantics for the host as for the guest. * * We pass through MADV_WIPEONFORK and MADV_KEEPONFORK if possible and * return failure if not. @@ -984,7 +966,7 @@ abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice) ret = -EINVAL; /* fall through */ case MADV_DONTNEED: - if (can_passthrough_madvise(start, end)) { + if (page_check_range(start, len, PAGE_PASSTHROUGH)) { ret = get_errno(madvise(g2h_untagged(start), len, advice)); if ((advice == MADV_DONTNEED) && (ret == 0)) { page_reset_target_data(start, start + len - 1); From patchwork Sun Jul 9 18:29:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700914 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4830133wrs; Sun, 9 Jul 2023 11:42:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlEVT8y2cSh+MSZnb+2J8JpT8fDE6iv3E/yXXBtCDksW/n9bvDhXMXgszo9gNZFYoFlpya+2 X-Received: by 2002:a0c:f443:0:b0:636:668e:7e6e with SMTP id h3-20020a0cf443000000b00636668e7e6emr8023673qvm.45.1688928169707; Sun, 09 Jul 2023 11:42:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688928169; cv=none; d=google.com; s=arc-20160816; b=NzEdDiis9ok6TDiggkRgWksifvYowAXsaWb0Q2CBmqzytbzRmp4LuXLP7qP/gkKjfY tj9llT2cMoy8qapZkl02P8079WnxnbPjltvMQyaZnm+a+kuMdfUh4bZhCm9Os0SkN2pq jKzMQa4fOa/7cn5Bg01PJih5Yad6+1iEs2s4i5vPJomToEVhehJ0HoCNm7VYVURxUl0y dLE/bxQDelPo4tnJuGC0cLUFIT5OkCnM+8b2KgoGympT/JeRk75tgWnMPJ0uNuqCBo0x qeQnySUlUv77lOmVFyfwMWPreOzEu0tvBcGtWmaUnsBVaqEK/z9OScism8B37AvbYXiI 1o+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:cc:to :from:dkim-signature; bh=vXDNUHkoHKMJOTYkZxcm9eNGIwvNIgvNekBczYJkm1c=; fh=4nfr0hkxlMpWE4oToQ1q4rzQVecv6te3cGVRc3YFjiI=; b=Y1VKruq1CkrIB2bpscMIkWSSU6+xOpMDecp0ktmURfHWEPwacX3Ub0mhzHCbfkR8/l p93vBGpMLVfYskF21gsRbJFYDeIrCPXCaLcy5LfQqckdBrI48UkLMX9Y2Bp3iclQMlbw wmEV9IG7YkuNhVIyF4/d2CPEBez1h3pxslKIsCiXX2sJ4DejnHPuLnOX1t9t1uUl4+TY NYPZW5auHCVspvfBTmdR6esBrgwFy4HAWUX31V8LRk9FPKixklJYBLUK3UTXzyRS/oP6 T6vaduD5FApK7F6U8Q85B8+Xz/rOPO8i9p1+KNtj3WhPT2sBV3rTDXU7aMRWZImZr4AL 2eFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="POT/JoZr"; 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 s5-20020a05620a030500b00763978e06f7si5014118qkm.384.2023.07.09.11.42.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:42:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="POT/JoZr"; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZHI-0003tU-Ri; Sun, 09 Jul 2023 14:37:00 -0400 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 1qIZH7-0003pg-Iw for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:36:50 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZH4-00051j-BJ for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:36:47 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3fbc0609cd6so37270055e9.1 for ; Sun, 09 Jul 2023 11:36:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927805; x=1691519805; 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=vXDNUHkoHKMJOTYkZxcm9eNGIwvNIgvNekBczYJkm1c=; b=POT/JoZrzkE6XvE3VWyv+BKAhZKWkHqbLjOAKAE/ZZ+pmGDcLSUgUevY47h8+fWOCT 4YWh71Gps1pvOn8bEnzbGXPif1FtW79MkyyAq0wIzCUD+gFSwNgsHIZZKHTOngK7mA4g 5xPjlJHOE2T5KVLyyb98R11yOnOTs7Yvbp0piYORFE1sw3qUvljXWl3l3IAstCGchzhI tNMwU5TEUkH/cSA7w71MJgg6eaWaApan25AAh6Z4F7UCLsNhBtE7LQJjCmtVm45Jvg4C qBR4b/vG+dHg7tTph6cV+zKJU935jJNz9MQ6RgsP/MnPSNfCyDDbNKCdfWAaZxkPbep+ PUUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927805; x=1691519805; 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=vXDNUHkoHKMJOTYkZxcm9eNGIwvNIgvNekBczYJkm1c=; b=G+grdaF63CLkeOKlxzRTlvMcWJruDFyKPkPnAaSMSiFhdKAoKwxvfzpuczJ1b49mGo Mrl82LhKlXTpWf7z8PjzNdq/aKYBv6EJST2NH/jT++0hfq9Fg6pzciNgUPM5JSaTY2oL 6EaHzEsLoytaSPy96hGYE9IxtD6bZTIKmTJof6+qnBrLvKR3pM3RubfWppae9yEhIk2y uI5GoBKGLJneHRK6ja5M9GvCcvoghXGKJrmgSD6yrQl6hrbVcThiWnFYKNSuP1JL6r/7 cDqeqY5V42hSriGIEcVativGV/G+xY8o4QGvoWIE/xKox6W8jbhq/hNrgBNWimxkeiAG NiAw== X-Gm-Message-State: ABy/qLZPFQUlVu9iVayyqC9Z/PP6J1LDrH6RD8/fSH8wnLW9TI6EhoV4 TxHCG++PUdflCBiE4UGEefLBEezG7xa3/ING+Xhm6Q== X-Received: by 2002:a05:600c:286:b0:3fc:4e0:be97 with SMTP id 6-20020a05600c028600b003fc04e0be97mr2790670wmk.6.1688927804950; Sun, 09 Jul 2023 11:36:44 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id i6-20020a5d6306000000b00313de682eb3sm9735832wru.65.2023.07.09.11.36.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:36:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH 43/45] linux-user: Simplify target_madvise Date: Sun, 9 Jul 2023 19:29:32 +0100 Message-Id: <20230709182934.309468-81-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32b.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The trivial length 0 check can be moved up, simplifying some of the other cases. The end < start test is handled by guest_range_valid_untagged. Signed-off-by: Richard Henderson Message-Id: <20230707204054.8792-27-richard.henderson@linaro.org> --- linux-user/mmap.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 49cfa873e0..44b53bd446 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -900,28 +900,17 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice) { - abi_ulong len, end; + abi_ulong len; int ret = 0; if (start & ~TARGET_PAGE_MASK) { return -TARGET_EINVAL; } - len = TARGET_PAGE_ALIGN(len_in); - - if (len_in && !len) { - return -TARGET_EINVAL; - } - - end = start + len; - if (end < start) { - return -TARGET_EINVAL; - } - - if (end == start) { + if (len_in == 0) { return 0; } - - if (!guest_range_valid_untagged(start, len)) { + len = TARGET_PAGE_ALIGN(len_in); + if (len == 0 || !guest_range_valid_untagged(start, len)) { return -TARGET_EINVAL; } From patchwork Sun Jul 9 18:29:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700925 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4830529wrs; Sun, 9 Jul 2023 11:44:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlHjNK+pM9iyOpga1yQi4kejWXqMYvMVMOGQmF7fhVNSGWyqoJI2k/9nz2HNWkV0Wn+u+elD X-Received: by 2002:ac8:4e92:0:b0:400:a5de:172 with SMTP id 18-20020ac84e92000000b00400a5de0172mr10031063qtp.4.1688928269381; Sun, 09 Jul 2023 11:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688928269; cv=none; d=google.com; s=arc-20160816; b=BDTdDDiIlgWnk6J64pKphatPX4aYMb8lpqcG25xQMBN4mDa0m3U0ejK15SKdDw3XzB JOWrRmP8zBCGCZxBOwPgrZw83SGNv+/3YyWGH4ePpI+Jje3FvLRxkI3lv26uKXhb3b0j RfSGFn2H4pkJl51rOQCN2/i1xtMJMhmItzADeKn7mM0p4ii8QX1y6CoFpxwQUmSy5lbP 63QkLKr9fCS+04l/ZcSta5zunl/xneqNPboytshYHvVnfxJoASqB/8CV49R95Np8ASPy iMR0GO4aeoqXxrPvRICzw5iFz6LknGvDGDYRcLy1mkypoCP/anBiycPYPHJLRjyyfkpm pAMw== 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:cc:to :from:dkim-signature; bh=I3ntvwGeIvPIaD5TgXh48cA42oiiDsy6pVSZ4qqqrPg=; fh=21Zix86sFserLD14mPs/66WMyjmNduwree2gPokjbXY=; b=yxWELChTzM/hzevSlv53g7GSuAMqhrk8GsWL4mkvGhC0z95y3Op17ZuuKI/9rtBZMW rB98cYrDQLqZyFPia4STZYgtY0AvYWW5izKMAakSccXjP8Rz8HNH7x21R3KRj5AtFsCl M5jAtAxiYzwusbM4EX+CdI3jovUdvtfuS4xiF7DWAyP0YuzvB/HkYeh8hP9xgHG4VklP meTJqKDJ1ApG+ygTTAPBPaHwD9aRiiC5LBIItNSmqAudeUMAFiNWGlhCr+PBK6Q7uhW/ mL8bFO1YJDJgCWSAvh7QIfqIyONBO9h9UGfGbJ1s0tkTjAie1KlIEm1HSvYODI3U1brB JDUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I6RtJRlY; 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 f12-20020ac87f0c000000b004035dadf9f5si4737001qtk.700.2023.07.09.11.44.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:44:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I6RtJRlY; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZHM-00048Y-Dl; Sun, 09 Jul 2023 14:37:04 -0400 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 1qIZHA-0003q6-C8 for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:36:52 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZH6-000520-DU for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:36:49 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fbc5d5742eso41929975e9.3 for ; Sun, 09 Jul 2023 11:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927806; x=1691519806; 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=I3ntvwGeIvPIaD5TgXh48cA42oiiDsy6pVSZ4qqqrPg=; b=I6RtJRlYfIX2gkBLiXywdeJkqegBhnkimgH/j7Ms9pzErqrTSoyCtQdhGubAIWGpx2 L65Kfi5PgggasHSKcQeOj/cNlkG7e6FlFmWDoZnqRjn+/w4qj6QXY5QlTyR4rbnNvm3i iqWTLwrpwV8jmhZjEIVJMLCyWdOrDs90gkPqLH9FMwpzGQTjvVcQwLG/TuL2GSCfu6UK q4d2UjvXHGKNsiaEwb4xX3UCsuTDn0FonPpBHvnEcxd6bMfBunmYLwDQVu+7CvVhbZ/E W1mOgNI4WMHx0WWl+dYrQmBmBUKpAc7Ho9ayy6NESTf0w4cxKpHbtm/V1N2C1T/GJ+7e imLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927806; x=1691519806; 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=I3ntvwGeIvPIaD5TgXh48cA42oiiDsy6pVSZ4qqqrPg=; b=jAlNorE8BM2CuYVRrT0WoktKOgOAB2SBSqeALSXr25rPPNabcAPFFKBKrhtIFwLHq3 r/kqPhz/YR/gO+ZvLm4NUE4sNGz9HPQKzfqn2YCwbu5pxxHY3DyxYQhUxIlgfIgvee6z ZLH2kqOBr6v32GyWtDiiSX20KvA5LGpJCilkQnJOHpKf4tjL2e1sPtiishmWElNvi2QV XEmCGKBfu1op+aMd/cjyv1kFb1N5kcCxwlcsW2CvcyoY0kHDj1wlfvbZs5Fj3y9ZVjuV Aum8Z/gkHw53tKu2SaCKiQgpwLa3LTGc1lv2W+p1DAxaM+X1bPtczTVATyajtrw+NbhA rQ+w== X-Gm-Message-State: ABy/qLaLH9sT7/a/vMu/GFQsZEDSpV6HDaZzwJWccNPk660AM/+DHTuD 8YSqT2a4Www5ocKJWa+iKPzxX3YfxSa8naLElN3SbQ== X-Received: by 2002:a1c:cc0d:0:b0:3fb:b1fd:4183 with SMTP id h13-20020a1ccc0d000000b003fbb1fd4183mr10007347wmb.12.1688927806067; Sun, 09 Jul 2023 11:36:46 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id i6-20020a5d6306000000b00313de682eb3sm9735832wru.65.2023.07.09.11.36.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:36:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Juan Quintela , =?utf-8?q?Philip?= =?utf-8?q?pe_Mathieu-Daud=C3=A9?= Subject: [PATCH 44/45] linux-user: Drop uint and ulong Date: Sun, 9 Jul 2023 19:29:33 +0100 Message-Id: <20230709182934.309468-82-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32f.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Juan Quintela These are types not used anymore anywhere else. Signed-off-by: Juan Quintela Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Message-id: <20230511085056.13809-1-quintela@redhat.com> Signed-off-by: Richard Henderson --- linux-user/syscall.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5870eb84e5..d2d6cad59d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -309,16 +309,16 @@ _syscall0(int, sys_gettid) #endif #if defined(TARGET_NR_getdents) && defined(EMULATE_GETDENTS_WITH_GETDENTS) -_syscall3(int, sys_getdents, uint, fd, struct linux_dirent *, dirp, uint, count); +_syscall3(int, sys_getdents, unsigned int, fd, struct linux_dirent *, dirp, unsigned int, count); #endif #if (defined(TARGET_NR_getdents) && \ !defined(EMULATE_GETDENTS_WITH_GETDENTS)) || \ (defined(TARGET_NR_getdents64) && defined(__NR_getdents64)) -_syscall3(int, sys_getdents64, uint, fd, struct linux_dirent64 *, dirp, uint, count); +_syscall3(int, sys_getdents64, unsigned int, fd, struct linux_dirent64 *, dirp, unsigned int, count); #endif #if defined(TARGET_NR__llseek) && defined(__NR_llseek) -_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, - loff_t *, res, uint, wh); +_syscall5(int, _llseek, unsigned int, fd, unsigned long, hi, unsigned long, lo, + loff_t *, res, unsigned int, wh); #endif _syscall3(int, sys_rt_sigqueueinfo, pid_t, pid, int, sig, siginfo_t *, uinfo) _syscall4(int, sys_rt_tgsigqueueinfo, pid_t, pid, pid_t, tid, int, sig, From patchwork Sun Jul 9 18:29:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700926 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4830528wrs; Sun, 9 Jul 2023 11:44:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlEjHQqMTUFsegC47Lr1LawBQPmLMliCR1Erf1aF5DqeAFffFZtkF8jjNREKpB7cvuI0sBph X-Received: by 2002:ac8:5d49:0:b0:403:3c39:c769 with SMTP id g9-20020ac85d49000000b004033c39c769mr10972729qtx.31.1688928269272; Sun, 09 Jul 2023 11:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688928269; cv=none; d=google.com; s=arc-20160816; b=DfPMfkQ6CL1Ph9WjPZUfIlwe7ktvPCv0xNgmHmGlOK0fukJBMHoWzywOAy+br4JZAY 662iI74aBgaT+Q6XQpUNACP9earYWfK8/0hMX0imOcLT727CZXUzne5y34+gmoAeN+Oc 5OEaxw2e3R35G9oFxS+yeN/oxNp4PhXV4rMMKNv75TAxxyb0dXaUlY76uhXtYLmhkxX+ kz96xisPGCbjQKsnCd0ucG9Cm4X59fEtGiuq+weYkwPw7XAaU5H4jnHbYy+fSiKH5NSc hhD9KTf/uTfGOWDwBos8BOYc1VgNYEhqxRzbjT91jhdq8TiqLh+s8Sx4dqkfZ37wBNAL yKHQ== 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:cc:to :from:dkim-signature; bh=b9LuMYd95477+OXo1OAWP9AY4NBDJaRVHD5duuyt7VI=; fh=N3SMljxyOUFIuGqCgVhtUoieeGv4bn21BMyeZcHajsI=; b=VxrerLdt218uq/BEZz1F0eNyyyvyilcKW+VocpayFu85M0sYv1F5LdjSwnoESz9edT Zn8/nt0gtxVsbLlg1b+1tpBCMlpnF4dCQzvsBtWB6g9JA+lmLqc7VvdR9ET/N53yQOiH UUzquBH7ox7oANkeRG2HKCZ+7Q4r2snk/jVfHyqgybKuTFydXvqL9vZNPqzgLOG5vGQs PmfHQ4IUp3NWesVUsguBHcBXwzwrOKF10oG/uvSO0LGe8PZa1LCZHN9Q09mgUJ6g0+4l zWcfxAOzlNlygTSdR4H2oJmrjfNXFlDJ1jKoj8IuFt0yfNW/LDu5sPVRzhoooyAU5hjc /K4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=huI4hDVO; 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 b8-20020ac85bc8000000b00400a950350asi4735708qtb.771.2023.07.09.11.44.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:44:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=huI4hDVO; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZHM-00046Q-4H; Sun, 09 Jul 2023 14:37:04 -0400 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 1qIZHB-0003qL-IA for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:36:53 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZH6-00052D-KR for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:36:51 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3fbc1218262so43742485e9.3 for ; Sun, 09 Jul 2023 11:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927807; x=1691519807; 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=b9LuMYd95477+OXo1OAWP9AY4NBDJaRVHD5duuyt7VI=; b=huI4hDVO5hshjqT2LARath/+I6pZftVoaugSK/rhSxnHRM7zemKSWfocNQ7QB0F/Fm B2M1mViDz/zTPzYWeMAJw6VYJ/Fw5cinVVobNvXX57b9TWbBZIuqD8WgQERI6joExRPV OzIFrQqXEgb+PJ++Q5pOV0lRkl1zdo+jwM+lfgGTQ/b0b3fFJyWKXSKxmByokj04oO8o uDn+2W0m0as8R0Vyzu8OwEWYJBOoHuSBh8WZfTuy7OVjLdVXhsYbUaXrsKn3zmPsLv1n 2mhWKcPmQq7SZdgHGSk5kWsAVKO1b4sScePvN53SPj3w8P9qo3V4f12D4J0e3AZAehNc pTbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927807; x=1691519807; 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=b9LuMYd95477+OXo1OAWP9AY4NBDJaRVHD5duuyt7VI=; b=ElebTNRLuPF1unNXZvm7C0rtlLBeYx6dYbsydbT8A6X0JF9/9ImAfietUgFGAqHe9q no4iTNLS7P1+XE0UEr4IvYlnJiwCF4I3IdsVkm5hdn1tbln5vki9bffcPPKNtOfKUe6z YQZfso8TyoMo1IC4SYR88dPd1OKCeUSe9fksIPNDptQw863HsDS6YjC5KzCjEQ8F3Z1w Vu76z5baEflb+AOGgheObd18DFPz+l4VxZyL1WdjyugCLVH2jEbDTRb2LUVY2ukTDTfV +uXGNtBrK6NMaHhOB/+nfi1pRfju4qRwEsjWiyvz+D+hKlkqJMoebekvWdJ8tRXPwMfJ QlsA== X-Gm-Message-State: ABy/qLYW3YFVzyialv2DC8EYMj9jzhyu3gdHeLrzD53IV1j2VpIXk1AK MS4uSj+vUFDYUaHkvEPMFDZYjHNTMxymzSe2WTaAVg== X-Received: by 2002:a7b:cb8d:0:b0:3fc:b78:fec6 with SMTP id m13-20020a7bcb8d000000b003fc0b78fec6mr3007904wmi.7.1688927806941; Sun, 09 Jul 2023 11:36:46 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id i6-20020a5d6306000000b00313de682eb3sm9735832wru.65.2023.07.09.11.36.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:36:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Robbin Ehn , Palmer Dabbelt Subject: [PATCH 45/45] linux-user/riscv: Add syscall riscv_hwprobe Date: Sun, 9 Jul 2023 19:29:34 +0100 Message-Id: <20230709182934.309468-83-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x332.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Robbin Ehn This patch adds the new syscall for the "RISC-V Hardware Probing Interface" (https://docs.kernel.org/riscv/hwprobe.html). Signed-off-by: Robbin Ehn Reviewed-by: Palmer Dabbelt Message-Id: <7f8d733df6e9b6151e9efb843d55441348805e70.camel@rivosinc.com> Signed-off-by: Richard Henderson --- linux-user/riscv/syscall32_nr.h | 1 + linux-user/riscv/syscall64_nr.h | 1 + linux-user/syscall.c | 146 ++++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+) diff --git a/linux-user/riscv/syscall32_nr.h b/linux-user/riscv/syscall32_nr.h index 1327d7dffa..412e58e5b2 100644 --- a/linux-user/riscv/syscall32_nr.h +++ b/linux-user/riscv/syscall32_nr.h @@ -228,6 +228,7 @@ #define TARGET_NR_accept4 242 #define TARGET_NR_arch_specific_syscall 244 #define TARGET_NR_riscv_flush_icache (TARGET_NR_arch_specific_syscall + 15) +#define TARGET_NR_riscv_hwprobe (TARGET_NR_arch_specific_syscall + 14) #define TARGET_NR_prlimit64 261 #define TARGET_NR_fanotify_init 262 #define TARGET_NR_fanotify_mark 263 diff --git a/linux-user/riscv/syscall64_nr.h b/linux-user/riscv/syscall64_nr.h index 6659751933..29e1eb2075 100644 --- a/linux-user/riscv/syscall64_nr.h +++ b/linux-user/riscv/syscall64_nr.h @@ -251,6 +251,7 @@ #define TARGET_NR_recvmmsg 243 #define TARGET_NR_arch_specific_syscall 244 #define TARGET_NR_riscv_flush_icache (TARGET_NR_arch_specific_syscall + 15) +#define TARGET_NR_riscv_hwprobe (TARGET_NR_arch_specific_syscall + 14) #define TARGET_NR_wait4 260 #define TARGET_NR_prlimit64 261 #define TARGET_NR_fanotify_init 262 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d2d6cad59d..4e5ccd0886 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8989,6 +8989,147 @@ static int do_getdents64(abi_long dirfd, abi_long arg2, abi_long count) } #endif /* TARGET_NR_getdents64 */ +#if defined(TARGET_NR_riscv_hwprobe) + +#define RISCV_HWPROBE_KEY_MVENDORID 0 +#define RISCV_HWPROBE_KEY_MARCHID 1 +#define RISCV_HWPROBE_KEY_MIMPID 2 + +#define RISCV_HWPROBE_KEY_BASE_BEHAVIOR 3 +#define RISCV_HWPROBE_BASE_BEHAVIOR_IMA (1 << 0) + +#define RISCV_HWPROBE_KEY_IMA_EXT_0 4 +#define RISCV_HWPROBE_IMA_FD (1 << 0) +#define RISCV_HWPROBE_IMA_C (1 << 1) + +#define RISCV_HWPROBE_KEY_CPUPERF_0 5 +#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0) +#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0) +#define RISCV_HWPROBE_MISALIGNED_SLOW (2 << 0) +#define RISCV_HWPROBE_MISALIGNED_FAST (3 << 0) +#define RISCV_HWPROBE_MISALIGNED_UNSUPPORTED (4 << 0) +#define RISCV_HWPROBE_MISALIGNED_MASK (7 << 0) + +struct riscv_hwprobe { + abi_llong key; + abi_ullong value; +}; + +static void risc_hwprobe_fill_pairs(CPURISCVState *env, + struct riscv_hwprobe *pair, + size_t pair_count) +{ + const RISCVCPUConfig *cfg = riscv_cpu_cfg(env); + + for (; pair_count > 0; pair_count--, pair++) { + abi_llong key; + abi_ullong value; + __put_user(0, &pair->value); + __get_user(key, &pair->key); + switch (key) { + case RISCV_HWPROBE_KEY_MVENDORID: + __put_user(cfg->mvendorid, &pair->value); + break; + case RISCV_HWPROBE_KEY_MARCHID: + __put_user(cfg->marchid, &pair->value); + break; + case RISCV_HWPROBE_KEY_MIMPID: + __put_user(cfg->mimpid, &pair->value); + break; + case RISCV_HWPROBE_KEY_BASE_BEHAVIOR: + value = riscv_has_ext(env, RVI) && + riscv_has_ext(env, RVM) && + riscv_has_ext(env, RVA) ? + RISCV_HWPROBE_BASE_BEHAVIOR_IMA : 0; + __put_user(value, &pair->value); + break; + case RISCV_HWPROBE_KEY_IMA_EXT_0: + value = riscv_has_ext(env, RVF) && + riscv_has_ext(env, RVD) ? + RISCV_HWPROBE_IMA_FD : 0; + value |= riscv_has_ext(env, RVC) ? + RISCV_HWPROBE_IMA_C : pair->value; + __put_user(value, &pair->value); + break; + case RISCV_HWPROBE_KEY_CPUPERF_0: + __put_user(RISCV_HWPROBE_MISALIGNED_FAST, &pair->value); + break; + default: + __put_user(-1, &pair->key); + break; + } + } +} + +static int cpu_set_valid(abi_long arg3, abi_long arg4) +{ + int ret, i, tmp; + size_t host_mask_size, target_mask_size; + unsigned long *host_mask; + + /* + * cpu_set_t represent CPU masks as bit masks of type unsigned long *. + * arg3 contains the cpu count. + */ + tmp = (8 * sizeof(abi_ulong)); + target_mask_size = ((arg3 + tmp - 1) / tmp) * sizeof(abi_ulong); + host_mask_size = (target_mask_size + (sizeof(*host_mask) - 1)) & + ~(sizeof(*host_mask) - 1); + + host_mask = alloca(host_mask_size); + + ret = target_to_host_cpu_mask(host_mask, host_mask_size, + arg4, target_mask_size); + if (ret != 0) { + return ret; + } + + for (i = 0 ; i < host_mask_size / sizeof(*host_mask); i++) { + if (host_mask[i] != 0) { + return 0; + } + } + return -TARGET_EINVAL; +} + +static abi_long do_riscv_hwprobe(CPUArchState *cpu_env, abi_long arg1, + abi_long arg2, abi_long arg3, + abi_long arg4, abi_long arg5) +{ + int ret; + struct riscv_hwprobe *host_pairs; + + /* flags must be 0 */ + if (arg5 != 0) { + return -TARGET_EINVAL; + } + + /* check cpu_set */ + if (arg3 != 0) { + ret = cpu_set_valid(arg3, arg4); + if (ret != 0) { + return ret; + } + } else if (arg4 != 0) { + return -TARGET_EINVAL; + } + + /* no pairs */ + if (arg2 == 0) { + return 0; + } + + host_pairs = lock_user(VERIFY_WRITE, arg1, + sizeof(*host_pairs) * (size_t)arg2, 0); + if (host_pairs == NULL) { + return -TARGET_EFAULT; + } + risc_hwprobe_fill_pairs(cpu_env, host_pairs, arg2); + unlock_user(host_pairs, arg1, sizeof(*host_pairs) * (size_t)arg2); + return 0; +} +#endif /* TARGET_NR_riscv_hwprobe */ + #if defined(TARGET_NR_pivot_root) && defined(__NR_pivot_root) _syscall2(int, pivot_root, const char *, new_root, const char *, put_old) #endif @@ -13671,6 +13812,11 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, return ret; #endif +#if defined(TARGET_NR_riscv_hwprobe) + case TARGET_NR_riscv_hwprobe: + return do_riscv_hwprobe(cpu_env, arg1, arg2, arg3, arg4, arg5); +#endif + default: qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num); return -TARGET_ENOSYS;