From nobody Mon Dec 23 23:45:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1734633208; cv=none; d=zohomail.com; s=zohoarc; b=mlWN/Qvi1/rMV+j0zRaw5pRmcCtPqK8SFwpRstUzeeBu1e67OCXrwLsvaKr5hgLlrn+ETdZnGFA22lWsrb4PLNscpMuKKtHqqf+R5HF2cuHiy/vb1ECuNWq+hte59YJCJ+Z208POOmom0DPZ0c892vG+HejzfWC3k6x9wuOLmuQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734633208; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bgg3DZOeSktQgwpMFQWYfQpPjrdNqQXpM4wVQei4S9U=; b=ZmSPEQJTYK0aIvUMQ/hM5k/ETVOHU2leFxY+c+9AQM7UC0lPuW3PqEEsgbxKzStREW3VbVb2WU4RlFs5+MrpFMa7aUSOwPZNtMMOVsxrblhGvCCE9FmDMl8OFrSzSnH4nQvZdmYVX0iCjbBUUV70e5/VqRqCChbyeJW9ri5Kw/U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1734633208230264.84666955968; Thu, 19 Dec 2024 10:33:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOLJy-0002yt-G6; Thu, 19 Dec 2024 13:32:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tOLJt-0002wj-DT for qemu-devel@nongnu.org; Thu, 19 Dec 2024 13:32:21 -0500 Received: from mail-pf1-x42b.google.com ([2607:f8b0: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 1tOLJo-0002aI-HG for qemu-devel@nongnu.org; Thu, 19 Dec 2024 13:32:19 -0500 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-728f337a921so1230871b3a.3 for ; Thu, 19 Dec 2024 10:32:16 -0800 (PST) Received: from pc.. ([38.39.164.180]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad90b302sm1624733b3a.175.2024.12.19.10.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 10:32:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734633135; x=1735237935; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bgg3DZOeSktQgwpMFQWYfQpPjrdNqQXpM4wVQei4S9U=; b=EHb7JArwr4gT8ZL/1ZtLzvZHiRm11C2rh3qflZ7KufVmLF/11BIJK5rTZs7DTdZqN6 DwDCMj34yJhuEpAGho3D4I6HDhZOdpV7KlQTd58h+jabqtIXTqXASkhnQKxqWNmH8Mx8 2cWiy1PNkK1UWQo88TlQzADQSQLd6PnSH1HIBtOdYrQU2Hebo5k/4WQE7msgd91rUS9N Sw6od+sDTK+EXeAZhVThtQLVuUwC89Rw+nSHDRAwD6NI3lfOcbTflyRhPWZz+5fwIi1w pICx8Rt6OYYuFGlghUCOHMbECMXzjGiRy4DUeNUPZayGBbKTBdFyXB/d/Om8C2rr9A5y Bxrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734633135; x=1735237935; 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=bgg3DZOeSktQgwpMFQWYfQpPjrdNqQXpM4wVQei4S9U=; b=huZCKzlL5xb3mHWMUQCfSh/KwIj34+U8+2g9LL/X5bC3D4gs2Cmo8Z1jdYQZwIYVR+ gxXHsw66oW3ZrU/4d/2oPUHqIb9raaERuB/Q/19ydzMXen7otHvOOUPKP/0GPg76IiTP 1ooqXRfW3JNfYG0/qzzdYM8xyq6ZQWDrDwdmT1nabEKPXCF2dThAVdZNp0kXNA1EMRdw ek4/AaEh+ajbEGL9DeUKpaZ0E9cnAh9FYYu9oamAodJT8PU3dP3YNaZSgvFPFZCs2Ilu UrmFTUA9vg4Wlwjgmko9xhL3mI8oSuyuQ5ivCKNeVQJ081sgM/P5ILPpuke69KcqZhNZ alxw== X-Gm-Message-State: AOJu0YxK/abRbx/7F1DQ6HRego9UUq9J2VI7Zxdoy1h10p3+55RsS+IK s7MRdVZEL149DvHFHRmjkqwTicMhUpNloKaTD48bo2LHFLOXY5CcRTcNBzBULbte/W570TNPwLU TenA= X-Gm-Gg: ASbGnctCwe6lu/ALhTZqrqBMh/vCd2RUMJ1lFKqH+Kb2QVZPF0QcSLA4MfcMSVNq0wm GoXQ7kvX5VYEKkDyqbhDcQxZX50JvM45+E2hNrlNu4GmbjSxaTr1xSgHm5tLVtjR5F8KYR/KArq P3HvhNC7qUr3XqmjDmVB1Zh98yzNMb3gm7tPPK9tyE/L+b2hmr+chOhO0tLX17YVU3HRZF3kNNc UhleTgV3z7ECNCaFH8E3IB2Ztm/1GEuaFYf1x0XbE327IrwsFTyqwEl X-Google-Smtp-Source: AGHT+IGF+rRqeIO/bCUN5wAwJFBz7SmxzQKFiaqqz696UQGWaKpxx8rf70FBqiqEPKLWfIIKZTyu+Q== X-Received: by 2002:a05:6a00:1909:b0:71e:6b8:2f4a with SMTP id d2e1a72fcca58-72aa8d3a152mr6906058b3a.12.1734633135047; Thu, 19 Dec 2024 10:32:15 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Fabiano Rosas , Peter Maydell , Yanan Wang , Zhao Liu , qemu-arm@nongnu.org, Laurent Vivier , alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Marcel Apfelbaum , Pierrick Bouvier Subject: [PATCH v2 1/3] target/arm: add new property to select pauth-qarma5 Date: Thu, 19 Dec 2024 10:32:09 -0800 Message-Id: <20241219183211.3493974-2-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241219183211.3493974-1-pierrick.bouvier@linaro.org> References: <20241219183211.3493974-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pf1-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 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1734633211380116600 Content-Type: text/plain; charset="utf-8" Before changing default pauth algorithm, we need to make sure current default one (QARMA5) can still be selected. $ qemu-system-aarch64 -cpu max,pauth-qarma5=3Don ... Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- docs/system/arm/cpu-features.rst | 5 ++++- target/arm/cpu.h | 1 + target/arm/arm-qmp-cmds.c | 2 +- target/arm/cpu64.c | 20 ++++++++++++++------ tests/qtest/arm-cpu-features.c | 15 +++++++++++---- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-feature= s.rst index a5fb929243c..d69ebc2b852 100644 --- a/docs/system/arm/cpu-features.rst +++ b/docs/system/arm/cpu-features.rst @@ -219,7 +219,10 @@ Below is the list of TCG VCPU features and their descr= iptions. ``pauth-qarma3`` When ``pauth`` is enabled, select the architected QARMA3 algorithm. =20 -Without either ``pauth-impdef`` or ``pauth-qarma3`` enabled, +``pauth-qarma5`` + When ``pauth`` is enabled, select the architected QARMA5 algorithm. + +Without ``pauth-impdef``, ``pauth-qarma3`` or ``pauth-qarma5`` enabled, the architected QARMA5 algorithm is used. The architected QARMA5 and QARMA3 algorithms have good cryptographic properties, but can be quite slow to emulate. The impdef algorithm used by QEMU is diff --git a/target/arm/cpu.h b/target/arm/cpu.h index d86e641280d..b7500bebd7f 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1062,6 +1062,7 @@ struct ArchCPU { bool prop_pauth; bool prop_pauth_impdef; bool prop_pauth_qarma3; + bool prop_pauth_qarma5; bool prop_lpa2; =20 /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ diff --git a/target/arm/arm-qmp-cmds.c b/target/arm/arm-qmp-cmds.c index 3cc8cc738bb..33cea080d11 100644 --- a/target/arm/arm-qmp-cmds.c +++ b/target/arm/arm-qmp-cmds.c @@ -94,7 +94,7 @@ static const char *cpu_model_advertised_features[] =3D { "sve640", "sve768", "sve896", "sve1024", "sve1152", "sve1280", "sve1408", "sve1536", "sve1664", "sve1792", "sve1920", "sve2048", "kvm-no-adjvtime", "kvm-steal-time", - "pauth", "pauth-impdef", "pauth-qarma3", + "pauth", "pauth-impdef", "pauth-qarma3", "pauth-qarma5", NULL }; =20 diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index ec77c5b34ad..9a193d2b489 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -520,9 +520,12 @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) } =20 if (cpu->prop_pauth) { - if (cpu->prop_pauth_impdef && cpu->prop_pauth_qarma3) { + if ((cpu->prop_pauth_impdef && cpu->prop_pauth_qarma3) || + (cpu->prop_pauth_impdef && cpu->prop_pauth_qarma5) || + (cpu->prop_pauth_qarma3 && cpu->prop_pauth_qarma5)) { error_setg(errp, - "cannot enable both pauth-impdef and pauth-qarm= a3"); + "cannot enable pauth-impdef, pauth-qarma3 and " + "pauth-qarma5 at the same time"); return; } =20 @@ -532,13 +535,15 @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) } else if (cpu->prop_pauth_qarma3) { isar2 =3D FIELD_DP64(isar2, ID_AA64ISAR2, APA3, features); isar2 =3D FIELD_DP64(isar2, ID_AA64ISAR2, GPA3, 1); - } else { + } else { /* default is pauth-qarma5 */ isar1 =3D FIELD_DP64(isar1, ID_AA64ISAR1, APA, features); isar1 =3D FIELD_DP64(isar1, ID_AA64ISAR1, GPA, 1); } - } else if (cpu->prop_pauth_impdef || cpu->prop_pauth_qarma3) { - error_setg(errp, "cannot enable pauth-impdef or " - "pauth-qarma3 without pauth"); + } else if (cpu->prop_pauth_impdef || + cpu->prop_pauth_qarma3 || + cpu->prop_pauth_qarma5) { + error_setg(errp, "cannot enable pauth-impdef, pauth-qarma3 or " + "pauth-qarma5 without pauth"); error_append_hint(errp, "Add pauth=3Don to the CPU property li= st.\n"); } } @@ -553,6 +558,8 @@ static const Property arm_cpu_pauth_impdef_property =3D DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false); static const Property arm_cpu_pauth_qarma3_property =3D DEFINE_PROP_BOOL("pauth-qarma3", ARMCPU, prop_pauth_qarma3, false); +static Property arm_cpu_pauth_qarma5_property =3D + DEFINE_PROP_BOOL("pauth-qarma5", ARMCPU, prop_pauth_qarma5, false); =20 void aarch64_add_pauth_properties(Object *obj) { @@ -573,6 +580,7 @@ void aarch64_add_pauth_properties(Object *obj) } else { qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_proper= ty); qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_qarma3_proper= ty); + qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_qarma5_proper= ty); } } =20 diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c index cfd6f773535..98d6c970ea5 100644 --- a/tests/qtest/arm-cpu-features.c +++ b/tests/qtest/arm-cpu-features.c @@ -419,21 +419,28 @@ static void pauth_tests_default(QTestState *qts, cons= t char *cpu_type) assert_has_feature_enabled(qts, cpu_type, "pauth"); assert_has_feature_disabled(qts, cpu_type, "pauth-impdef"); assert_has_feature_disabled(qts, cpu_type, "pauth-qarma3"); + assert_has_feature_disabled(qts, cpu_type, "pauth-qarma5"); assert_set_feature(qts, cpu_type, "pauth", false); assert_set_feature(qts, cpu_type, "pauth", true); assert_set_feature(qts, cpu_type, "pauth-impdef", true); assert_set_feature(qts, cpu_type, "pauth-impdef", false); assert_set_feature(qts, cpu_type, "pauth-qarma3", true); assert_set_feature(qts, cpu_type, "pauth-qarma3", false); + assert_set_feature(qts, cpu_type, "pauth-qarma5", true); + assert_set_feature(qts, cpu_type, "pauth-qarma5", false); assert_error(qts, cpu_type, - "cannot enable pauth-impdef or pauth-qarma3 without pauth= ", + "cannot enable pauth-impdef, pauth-qarma3 or pauth-qarma5= without pauth", "{ 'pauth': false, 'pauth-impdef': true }"); assert_error(qts, cpu_type, - "cannot enable pauth-impdef or pauth-qarma3 without pauth= ", + "cannot enable pauth-impdef, pauth-qarma3 or pauth-qarma5= without pauth", "{ 'pauth': false, 'pauth-qarma3': true }"); assert_error(qts, cpu_type, - "cannot enable both pauth-impdef and pauth-qarma3", - "{ 'pauth': true, 'pauth-impdef': true, 'pauth-qarma3': t= rue }"); + "cannot enable pauth-impdef, pauth-qarma3 or pauth-qarma5= without pauth", + "{ 'pauth': false, 'pauth-qarma5': true }"); + assert_error(qts, cpu_type, + "cannot enable pauth-impdef, pauth-qarma3 and pauth-qarma= 5 at the same time", + "{ 'pauth': true, 'pauth-impdef': true, 'pauth-qarma3': t= rue," + " 'pauth-qarma5': true }"); } =20 static void test_query_cpu_model_expansion(const void *data) --=20 2.39.5 From nobody Mon Dec 23 23:45:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1734633207; cv=none; d=zohomail.com; s=zohoarc; b=G0UJT6TVXHO1+kK7NCT+BcyluJIz73GIYHeMss/8vAjgTLdfYXUJXv0PSoLvoEUhl20UKZIgtv087CsmK27W+1EiUhJpdOxdMDlFtTbyDIXPoKkxqxQQoN1iOMbrb9IlBiGUDp4e5va/rZpozkCBvYvvSLCVB8x/I+UMtlQvRdE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734633207; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Z34VbarymgQiW5Qnm/WH4E3Ova5VTGM3lSMYMRGrvZ8=; b=HHqGxOJ821J1ZzzAf8D9o5qC3J5UsTxuPzfrpbIOQti5hfLNgcjglRxvIXivzzMxsOGCqrtfqXT2xw6yYwJMkeP9H23HntCPKi1ERZ5Z4R7We8RdyfOWnh4PK2k9oKPj3xoVZLXVO3vUq/S7PftDVrr8DXmxGprXafX7ro0O7T8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1734633207466200.28483091144903; Thu, 19 Dec 2024 10:33:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOLK0-0002zc-08; Thu, 19 Dec 2024 13:32:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tOLJu-0002xa-96 for qemu-devel@nongnu.org; Thu, 19 Dec 2024 13:32:23 -0500 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tOLJp-0002aR-K7 for qemu-devel@nongnu.org; Thu, 19 Dec 2024 13:32:20 -0500 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-728e78c4d7bso899730b3a.0 for ; Thu, 19 Dec 2024 10:32:16 -0800 (PST) Received: from pc.. ([38.39.164.180]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad90b302sm1624733b3a.175.2024.12.19.10.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 10:32:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734633136; x=1735237936; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z34VbarymgQiW5Qnm/WH4E3Ova5VTGM3lSMYMRGrvZ8=; b=xkhcvJEEV1pghwCH7PAf5aCyrevXrJRGcxT3qCOH7DosXzcwbbD1BcKWZDqqRxbkq5 3vonvw/IzCF+3MKx7ANTCf5+tHkvzNLf5Zue1JrL0smB5P3XEqkrlE9gNhgwMmGXoA05 dvxQHKhGvJDEVwV46fm7teYTCCtqvUj+63jxglhS8ysoOjbSHTDt1QssxMK/8zobDD/6 RdyWz6kY5zZ3hxrUG6vlnI7h8KZy9k30f9VF5Mo1acqXH3tu1yYN1qgdA1n0l/JV8zW3 ds04FIzmo2e5KdPfxAT+luRc1FDKGZgPELyKK7mEDlEKrxw+oOnucmoHK2b5vXdw35MJ E8sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734633136; x=1735237936; 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=Z34VbarymgQiW5Qnm/WH4E3Ova5VTGM3lSMYMRGrvZ8=; b=dQFsRQLi6lwPaANQK+gvCXo+TcGtZ0YiFPfaXQmD2q3wcHv1o6bPHULA0YTFv11JJO lCYtf2t3/DAwDJfQY//JYC3i/UOH10HZ2FVjXYHac+NldY/NdTl+kY+vvZz5XSnFhefp f+z4+nlPuwTf83fhY5aI0V3RWmjWPmod72DktfgFztADjdQ/6e5Gu7oD7vpBf2unJ7LH UTBbSfut/QcYQZkE3ebfbUy15ZergAzUwxXcf1NZ/w8PZ/us8ROI/s4L1WA9fgh6I/fs 7iX1mMcDvGOMxRhAwtZm+Tu3PjS5MczfNIZEsRBXcUIV7qiMGIk5x4rYMRIDaETefJST R8Jw== X-Gm-Message-State: AOJu0YxCcUHcT/Xm7udQXwSp1yIYnipwHtU8uFy66uaINCypwoJUZVYT qrwcWgdbJq/YTAipdwsC++0dvVPQkd95Urniy665kZEfljBiRfARPtPz0f+jD+P3Bp/GzkHDacA ZtUE= X-Gm-Gg: ASbGncvPMd8PukWWQ2vSxwkWwtt4OWcLriCO+VL9oQqQOnDHADp/0H651ZaYXtb1lZr vvKETo/QYM/7/F5DrJrWIEKSUn/Jvm91hrBplYj7/xoweatyFTkXKkNP/L9agFnvXb6dPfACBqM GWgF+ZhImPsCkFY73U21w8y10IC33F+LKDkD5jTr+r59F8LgwYBuMzLouSkXeE3h7Ge4RtSGwSJ UQgyqxm9SSRu9taX/rJJuW1vlUX/p9F/1FC11eSnXyHt1TCwFP1tCTf X-Google-Smtp-Source: AGHT+IFoe8gDxr+alMHHQuTDU0AyJbhcDnWAM9pmiTIngaibjftJJMk+DYrmHuUZSjN3+tq20v0Xzg== X-Received: by 2002:a05:6a00:6c88:b0:728:15fd:dabb with SMTP id d2e1a72fcca58-72aa9a43affmr6562513b3a.8.1734633135964; Thu, 19 Dec 2024 10:32:15 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Fabiano Rosas , Peter Maydell , Yanan Wang , Zhao Liu , qemu-arm@nongnu.org, Laurent Vivier , alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Marcel Apfelbaum , Pierrick Bouvier Subject: [PATCH v2 2/3] target/arm: change default pauth algorithm to impdef Date: Thu, 19 Dec 2024 10:32:10 -0800 Message-Id: <20241219183211.3493974-3-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241219183211.3493974-1-pierrick.bouvier@linaro.org> References: <20241219183211.3493974-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pf1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1734633208521116600 Content-Type: text/plain; charset="utf-8" Pointer authentication on aarch64 is pretty expensive (up to 50% of execution time) when running a virtual machine with tcg and -cpu max (which enables pauth=3Don). The advice is always: use pauth-impdef=3Don. Our documentation even mentions it "by default" in docs/system/introduction.rst. Thus, we change the default to use impdef by default. This does not affect kvm or hvf acceleration, since pauth algorithm used is the one from host cpu. This change is retro compatible, in terms of cli, with previous versions, as the semantic of using -cpu max,pauth-impdef=3Don, and -cpu max,pauth-qarma3=3Don is preserved. The new option introduced in previous patch and matching old default is -cpu max,pauth-qarma5=3Don. It is retro compatible with migration as well, by defining a backcompat property, that will use qarma5 by default for virt machine <=3D 9.2. Tested by saving and restoring a vm from qemu 9.2.0 into qemu-master (10.0) for cpus neoverse-n2 and max. Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- docs/system/arm/cpu-features.rst | 2 +- docs/system/introduction.rst | 2 +- target/arm/cpu.h | 3 +++ hw/core/machine.c | 4 +++- target/arm/cpu.c | 2 ++ target/arm/cpu64.c | 22 ++++++++++++++++------ 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-feature= s.rst index d69ebc2b852..37d5dfd15b3 100644 --- a/docs/system/arm/cpu-features.rst +++ b/docs/system/arm/cpu-features.rst @@ -223,7 +223,7 @@ Below is the list of TCG VCPU features and their descri= ptions. When ``pauth`` is enabled, select the architected QARMA5 algorithm. =20 Without ``pauth-impdef``, ``pauth-qarma3`` or ``pauth-qarma5`` enabled, -the architected QARMA5 algorithm is used. The architected QARMA5 +the QEMU impdef algorithm is used. The architected QARMA5 and QARMA3 algorithms have good cryptographic properties, but can be quite slow to emulate. The impdef algorithm used by QEMU is non-cryptographic but significantly faster. diff --git a/docs/system/introduction.rst b/docs/system/introduction.rst index 746707eb00e..338d3745c3c 100644 --- a/docs/system/introduction.rst +++ b/docs/system/introduction.rst @@ -169,7 +169,7 @@ would default to it anyway. =20 .. code:: =20 - -cpu max,pauth-impdef=3Don \ + -cpu max \ -smp 4 \ -accel tcg \ =20 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index b7500bebd7f..276a7a557ba 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -972,6 +972,9 @@ struct ArchCPU { /* QOM property to indicate we should use the back-compat CNTFRQ defau= lt */ bool backcompat_cntfrq; =20 + /* QOM property to indicate we should use the back-compat QARMA5 defau= lt */ + bool backcompat_pauth_default_use_qarma5; + /* Specify the number of cores in this CPU cluster. Used for the L2CTLR * register. */ diff --git a/hw/core/machine.c b/hw/core/machine.c index d970f753e37..de1547994c4 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -36,7 +36,9 @@ #include "hw/virtio/virtio-iommu.h" #include "audio/audio.h" =20 -GlobalProperty hw_compat_9_2[] =3D {}; +GlobalProperty hw_compat_9_2[] =3D { + {"arm-cpu", "backcompat-pauth-default-use-qarma5", "true"}, +}; const size_t hw_compat_9_2_len =3D G_N_ELEMENTS(hw_compat_9_2); =20 GlobalProperty hw_compat_9_1[] =3D { diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 1afa07511e3..68f1ab639b8 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2652,6 +2652,8 @@ static const Property arm_cpu_properties[] =3D { DEFINE_PROP_INT32("core-count", ARMCPU, core_count, -1), /* True to default to the backward-compat old CNTFRQ rather than 1Ghz = */ DEFINE_PROP_BOOL("backcompat-cntfrq", ARMCPU, backcompat_cntfrq, false= ), + DEFINE_PROP_BOOL("backcompat-pauth-default-use-qarma5", ARMCPU, + backcompat_pauth_default_use_qarma5, false), DEFINE_PROP_END_OF_LIST() }; =20 diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 9a193d2b489..045b94fcb4d 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -529,15 +529,25 @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) return; } =20 - if (cpu->prop_pauth_impdef) { - isar1 =3D FIELD_DP64(isar1, ID_AA64ISAR1, API, features); - isar1 =3D FIELD_DP64(isar1, ID_AA64ISAR1, GPI, 1); + bool use_default =3D !cpu->prop_pauth_qarma5 && + !cpu->prop_pauth_qarma3 && + !cpu->prop_pauth_impdef; + + if (cpu->prop_pauth_qarma5 || + (use_default && + cpu->backcompat_pauth_default_use_qarma5)) { + isar1 =3D FIELD_DP64(isar1, ID_AA64ISAR1, APA, features); + isar1 =3D FIELD_DP64(isar1, ID_AA64ISAR1, GPA, 1); } else if (cpu->prop_pauth_qarma3) { isar2 =3D FIELD_DP64(isar2, ID_AA64ISAR2, APA3, features); isar2 =3D FIELD_DP64(isar2, ID_AA64ISAR2, GPA3, 1); - } else { /* default is pauth-qarma5 */ - isar1 =3D FIELD_DP64(isar1, ID_AA64ISAR1, APA, features); - isar1 =3D FIELD_DP64(isar1, ID_AA64ISAR1, GPA, 1); + } else if (cpu->prop_pauth_impdef || + (use_default && + !cpu->backcompat_pauth_default_use_qarma5)) { + isar1 =3D FIELD_DP64(isar1, ID_AA64ISAR1, API, features); + isar1 =3D FIELD_DP64(isar1, ID_AA64ISAR1, GPI, 1); + } else { + g_assert_not_reached(); } } else if (cpu->prop_pauth_impdef || cpu->prop_pauth_qarma3 || --=20 2.39.5 From nobody Mon Dec 23 23:45:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1734633208; cv=none; d=zohomail.com; s=zohoarc; b=BRLNCVY3hBZjdgzjV71d1YvDq1tDADHo0Kiuhzti/fVuRgO4g7myxVfULOSlNH3X1dQkWRvwTXDwM+Y8ixm8G687W6vLTYGXYaBNtmCnKo+G4JCHFphKL4dlcch3VatVvz/WiPvp4XC2zj3lSCrhnspojE8ufF7aYi/DQRX2PRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734633208; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VrAuDbFs90HcBriKC3fRwSGZ9LUrKAcdlzz9HBsoE2g=; b=fmR7TxndvKZmmbGGqAtqHUY5oUn7AkgcuOxPTXyco07MwqC8eC/hc4eOeuiJsJ1JpjuGito5yh/+jmeWvnv9nLbLr0vRQ7Zbntp/tp6zgDz43EjWWZDd9WeV3k2pDOyXk+8iRxbG81C8yN6s2rHTZ3DjYfSCUJ+0SwXljoz3cXc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1734633208825414.3974244992901; Thu, 19 Dec 2024 10:33:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOLK1-00030B-1v; Thu, 19 Dec 2024 13:32:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tOLJu-0002xb-9Y for qemu-devel@nongnu.org; Thu, 19 Dec 2024 13:32:23 -0500 Received: from mail-pf1-x42e.google.com ([2607:f8b0: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 1tOLJq-0002ac-5s for qemu-devel@nongnu.org; Thu, 19 Dec 2024 13:32:20 -0500 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-725d9f57d90so897454b3a.1 for ; Thu, 19 Dec 2024 10:32:17 -0800 (PST) Received: from pc.. ([38.39.164.180]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad90b302sm1624733b3a.175.2024.12.19.10.32.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 10:32:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734633137; x=1735237937; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VrAuDbFs90HcBriKC3fRwSGZ9LUrKAcdlzz9HBsoE2g=; b=TBD4mrezylnX8VJ8/Np0CukWli3N2MSwHuVVZEeqjH+Uthdo3Mc3FTtZKxvrUktzPQ zMpIj6HdURrCHyrKYlIG6JTagp/RyfI/jS6hi8I66cJNNUyK9oGSBvS5zaIUPf+//sQa 5K/ch0RaS4Z9sJH4xBUatKs+OM9tQ/bk4v/g9dtDObHejzf4jkx2HJQKNSZyVVIqpeqp MXviFIelO0ES6hg9ir+CKfccEJ7BR4aWPuBQEMQUxiDDDZEV2+M1dgeuEkOLpqcEmJnT LhI3peTwsHfxLCYGhW+A/s8kLQKQSsJ72O1iU4n+kyuGLmhuyNhFLGI436G7zWjPCeRK 8LvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734633137; x=1735237937; 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=VrAuDbFs90HcBriKC3fRwSGZ9LUrKAcdlzz9HBsoE2g=; b=PjSIvlHDRRfbcC2vXi2FLZftvT5hy6gv8Yz44cIMM5eflexj7uyOf9n380IVZU5Xl7 COp69Ti8zbDzOxgufFioWOoLvi99JKc7rjefdhmbD94RR2hy/+mi3AwFSzCBgjcpZf52 HMAKenOH1e9J8J2/OTOBjEl/100BMy4QRtDeStMMpCR0vU0+CTwTJpcXGomseGq00hwS sMQbd+G1hqSyZL1FS/Hkc8WEmjd5UtQDRu0TTEIiWH2ZzhpUCamn/hSpiobSAg8A4EB0 reLpmIFM9l0mTDH3UfzDAPURTiDM9qUGSiAcoTKUcVoWlKOiLvk+uUQcFhjHZ0vdTJlp ZFnA== X-Gm-Message-State: AOJu0YzQwLzfelWxbPRf9mdTtpaBBN5RIna2aO7SJuqf6EDcGeG3ozOI fC7DNF/S47RB2zlUFLoN03UsggdN86toGpK8r/7r7R/Kd+26wFc3THCZNItro8w/bjBCUz/te5u bBJw= X-Gm-Gg: ASbGncuFVJocDba+hop6tamdYaSq61vaKdTTiF5LPWYuguuxV8LcUTjCdvmS9uiW4FO MqA61Ne9CGslAy7/6fUzkQgcvhpCxF+H/wH7rSNi3nBQvlT3G2KAmCYU8NHMTb55uS09wpu4YmU f7pwAUpbMofepJHwHezNzKkO4o0EB/rMoDoABqnuWmeHr3HOGk8cJVp9nPcqTGvjob+WNLr3Kx0 T5EpXN168juJDq/v7Og8ZcCc6J0uGoobvPE50koObJOCqEtiWcL0XZf X-Google-Smtp-Source: AGHT+IErQi05wuFbtGW97Qfm0HdyAPfmS5ZIe6ijwUVMBvi4kz/COnJBsO0HHGKLbBRPi5jPh0/OtQ== X-Received: by 2002:a05:6a00:2189:b0:725:f212:12e5 with SMTP id d2e1a72fcca58-72abb5dcc67mr762718b3a.24.1734633136923; Thu, 19 Dec 2024 10:32:16 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Fabiano Rosas , Peter Maydell , Yanan Wang , Zhao Liu , qemu-arm@nongnu.org, Laurent Vivier , alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Marcel Apfelbaum , Pierrick Bouvier Subject: [PATCH v2 3/3] docs/system/arm/virt: mention specific migration information Date: Thu, 19 Dec 2024 10:32:11 -0800 Message-Id: <20241219183211.3493974-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241219183211.3493974-1-pierrick.bouvier@linaro.org> References: <20241219183211.3493974-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pf1-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, WEIRD_QUOTING=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1734633211203116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pierrick Bouvier --- docs/system/arm/virt.rst | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst index d25275c27ce..9f1457cf9a2 100644 --- a/docs/system/arm/virt.rst +++ b/docs/system/arm/virt.rst @@ -17,9 +17,17 @@ to have the same behaviour as that of previous QEMU rele= ases, so that VM migration will work between QEMU versions. For instance the ``virt-5.0`` machine type will behave like the ``virt`` machine from the QEMU 5.0 release, and migration should work between ``virt-5.0`` -of the 5.0 release and ``virt-5.0`` of the 5.1 release. Migration -is not guaranteed to work between different QEMU releases for -the non-versioned ``virt`` machine type. +of the 5.0 release and ``virt-5.0`` of the 5.1 release. + +When saving a VM using the ``virt`` model, the snapshot is automatically s= et to +target the latest ``virt`` versioned model. When loading the VM with a more +recent QEMU version, you'll need to set machine model to match the version= of +your snapshot. When loading it, QEMU will return an error with the expected +``virt`` version you should set, so you don't need to record it. + +VM migration is not guaranteed when using ``-cpu max``, as features suppor= ted +may change between QEMU versions. To ensure your VM can be migrated, it is +recommended to use another cpu model instead. =20 Supported devices """"""""""""""""" --=20 2.39.5