From nobody Tue Feb 10 07:42:07 2026 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=1658773339; cv=none; d=zohomail.com; s=zohoarc; b=R3XbXKRgUPO4odOxs8qu6AW0zBChyrkttqVrETID/44uBT16kQ5sDGeR4jklEarD71dO1Jq37wRFkUdzlKK41AjghHdQUgXJ+8//n1j7xgM0LMGkLts/XDtpk6sehJ6TJ9p8pytAo27KKGCukQti0+LynEhODTkkGNPba9ZnbUE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658773339; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N2OJQKKwRLRjFx/fh9iTaEVWiqAoFPuSiTt6AYqCB48=; b=UENnfhUaI/JzwYhqwiSItj3QTmRExnrsijYCiG/zlKO4zA87ncloV3tykzZAMxR0BFQjE/Nsqmu9g7VXGmgYkjm5QoHrGGkyTw0Y1wukCh5u2DlNHKtdXEaaPvcTCDUCNqfjUYA3oH1eGThxLqzt3c6D0x/haFkRrfE11O04on8= 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 1658773339861501.39905796301343; Mon, 25 Jul 2022 11:22:19 -0700 (PDT) Received: from localhost ([::1]:59932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oG2ig-00025B-06 for importer@patchew.org; Mon, 25 Jul 2022 14:22:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oG2bo-0004mh-82 for qemu-devel@nongnu.org; Mon, 25 Jul 2022 14:15:15 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:45638) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oG2bl-0005q9-E1 for qemu-devel@nongnu.org; Mon, 25 Jul 2022 14:15:11 -0400 Received: by mail-pj1-x1031.google.com with SMTP id g5-20020a17090a290500b001f2ea602563so258065pjd.4 for ; Mon, 25 Jul 2022 11:15:09 -0700 (PDT) Received: from stoup.. ([2602:ae:1549:801:30c1:2484:a853:233d]) by smtp.gmail.com with ESMTPSA id bg5-20020a1709028e8500b0016d8d277c02sm1125004plb.25.2022.07.25.11.15.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 11:15:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N2OJQKKwRLRjFx/fh9iTaEVWiqAoFPuSiTt6AYqCB48=; b=k4z62w5IpFLty3Sy7/0qLGS4SWQO4CjNegPSxpWly3VcZf0kSa3MzwL3M4+34CbLqa LhO166wyO+M/MVMahHYFFxJ7H01JznqF9r7NbhAoioPy8vi9YSASVFtEPlklaj2an2Ss k7UVdtb1Fj6G2gCTDMlP9X+a9TkrSxAzHGuPy5+jg0MDCHDYzOFw6FbNTTlnudA7DtJ6 OtjUVMv1N3d6Jfq/JvRFU2b1uPxtJqq0G4qoFUw3/AUtEn0yLFJ+BJsAiB3nyZeGoFDV et2p2QvXUaNQjN8F4Mz8I9sZMaBu23dvZo/mzJA0lJBnyKfNKDjAHuniH6cnJC1O9xsP SYsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N2OJQKKwRLRjFx/fh9iTaEVWiqAoFPuSiTt6AYqCB48=; b=56pmWyb669X1tRtuKN9v9VAQPhi7jyY4FQrm3+oWduz0WLhqh8xVzAD071uAwXwR1O j8nblDm1ZD5wQTH2sqMBDlNhDagR8al/ZdMYl/PW6td7w6ZETVb41Phg+IiystrEWu70 SzJH5LhT8t0paxtchAfx0phktZMm2wlTRkzpnQnBYUtycLMI9H0cH+Zs53S9yOyeIWQB U34rPHEZhM2wtNgS5v26ms8C6ojldB3ooVhD2eTquaxXHN/0eF5v8gYd/vpFlM1GZF3f vKrZFHQ3SpXAQao4HWWmeBQlzJ+5fqWXRuSfnkaqstuwDdaCJ07dAoS8Jv7Zm0Ca3Jil IY5A== X-Gm-Message-State: AJIora+l42+gbj3fV3o9FozSBZDU+2F2GAJxioe2YzP8rOJTtZCVdSKN xZKeCVGh3G/uTeh1YijtT0dLg6T9kzdB8A== X-Google-Smtp-Source: AGRyM1vNlm5NJPRWRznEPLaCoFG+T677SB5++0X1+X8SW8/nlaPXr5Pw+es5HEDBMdyFVYE67OT72g== X-Received: by 2002:a17:902:ec86:b0:16d:6424:efb2 with SMTP id x6-20020a170902ec8600b0016d6424efb2mr9952698plg.62.1658772908058; Mon, 25 Jul 2022 11:15:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: yuzenghui@huawei.com, qemu-arm@nongnu.org Subject: [PATCH 2/3] target/arm: Set KVM_ARM_VCPU_SVE while probing the host Date: Mon, 25 Jul 2022 11:14:56 -0700 Message-Id: <20220725181457.41083-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220725181457.41083-1-richard.henderson@linaro.org> References: <20220725181457.41083-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1658773340429100003 Content-Type: text/plain; charset="utf-8" Because we weren't setting this flag, our probe of ID_AA64ZFR0 was always returning zero. This also obviates the adjustment of ID_AA64PFR0, which had sanitized the SVE field. Reported-by: Zenghui Yu Signed-off-by: Richard Henderson --- target/arm/kvm64.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 36ff20c9e3..8b2ae9948a 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -512,7 +512,6 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *= ahcf) bool sve_supported; bool pmu_supported =3D false; uint64_t features =3D 0; - uint64_t t; int err; =20 /* Old kernels may not know about the PREFERRED_TARGET ioctl: however @@ -533,10 +532,17 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures= *ahcf) struct kvm_vcpu_init init =3D { .target =3D -1, }; =20 /* - * Ask for Pointer Authentication if supported. We can't play the - * SVE trick of synthesising the ID reg as KVM won't tell us - * whether we have the architected or IMPDEF version of PAuth, so - * we have to use the actual ID regs. + * Ask for SVE if supported, so that we can query ID_AA64ZFR0, + * which is otherwise RAZ. + */ + sve_supported =3D kvm_arm_svm_supported(); + if (sve_supported) { + init.features[0] |=3D 1 << KVM_ARM_VCPU_SVE; + } + + /* + * Ask for Pointer Authentication if supported, so that we get + * the unsanitized field values for AA64ISAR1_EL1. */ if (kvm_arm_pauth_supported()) { init.features[0] |=3D (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS | @@ -680,20 +686,13 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures= *ahcf) } } =20 - sve_supported =3D kvm_arm_svm_supported(); - - /* Add feature bits that can't appear until after VCPU init. */ if (sve_supported) { - t =3D ahcf->isar.id_aa64pfr0; - t =3D FIELD_DP64(t, ID_AA64PFR0, SVE, 1); - ahcf->isar.id_aa64pfr0 =3D t; - /* * There is a range of kernels between kernel commit 73433762fcae * and f81cb2c3ad41 which have a bug where the kernel doesn't expo= se * SYS_ID_AA64ZFR0_EL1 via the ONE_REG API unless the VM has enabl= ed - * SVE support, so we only read it here, rather than together with= all - * the other ID registers earlier. + * SVE support, which resulted in an error rather than RAZ. + * So only read the register if we set KVM_ARM_VCPU_SVE above. */ err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64zfr0, ARM64_SYS_REG(3, 0, 0, 4, 4)); --=20 2.34.1