From nobody Thu Sep 19 01:26:25 2024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA32E14B086 for ; Tue, 23 Jul 2024 07:20:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721719226; cv=none; b=Z4HxEi+2TyYSGrpwSj47FiBwTp+YM9kkM65ypAAotH7s4gGIY/xkmDGfHulgh11aGQ+Y9cy1rd3DZu+0QxUdyySCN2ecjTrXbwEZGbhurfYOXos9o4FlY8eXQJsIn0XwMqkMD7FPeZsAQtvxi/lAJ00ivofNwsLGOAbgLIB2Mdk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721719226; c=relaxed/simple; bh=uhRsYbCA0NHQbeKMtZ1HldKAz1j/cFiV4RW46nKzz9A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=p429Rm1UCQ9E5ECFX9WnjVtq3Vx6njD76Lh+/SEplfoF9lNPrysT2gYKL0QUMNU04LoZl4cSteThdAyiyEzAY+lYeEerEjuMXxFUWupZCnNkbV5QkFi+praoDXK8Cw00meuHHhlF31nKl/D/T169dmS5xPcwbjt+iqgljY/L0b8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=hbhsj/9S; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hbhsj/9S" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721719223; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vEFLN3C1npdDEFSgLdjRte39ulWAdAjqQadHX/VuSxs=; b=hbhsj/9SqxuyBEcHUQ4Uph9Rk3KT3ROEIEGeL6P62ytoxs9ryFP6GvYAn3BKEv+KWXC30o uwLri2AqzXJlDLc7nqzciZ0pekkxJhZLSfDSMzFhnL3h/vhQ3Zm8gFKPhjPHY5dRsIZ3QX Dy9bR0nE5WGf8MWDiZRil/dRRCIAbB4= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-372-I4BTyTP9ORiWisyCchxL_g-1; Tue, 23 Jul 2024 03:20:19 -0400 X-MC-Unique: I4BTyTP9ORiWisyCchxL_g-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A246419560A2; Tue, 23 Jul 2024 07:20:16 +0000 (UTC) Received: from virt-mtcollins-01.lab.eng.rdu2.redhat.com (virt-mtcollins-01.lab.eng.rdu2.redhat.com [10.8.1.196]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1B0E21955E70; Tue, 23 Jul 2024 07:20:13 +0000 (UTC) From: Shaoqin Huang To: Oliver Upton , Marc Zyngier , kvmarm@lists.linux.dev, Mark Brown Cc: Eric Auger , Sebastian Ott , Cornelia Huck , Shaoqin Huang , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/4] KVM: arm64: Disable fields that KVM doesn't know how to handle in ID_AA64PFR1_EL1 Date: Tue, 23 Jul 2024 03:20:00 -0400 Message-Id: <20240723072004.1470688-2-shahuang@redhat.com> In-Reply-To: <20240723072004.1470688-1-shahuang@redhat.com> References: <20240723072004.1470688-1-shahuang@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" For some of the fields in the ID_AA64PFR1_EL1 register, KVM doesn't know how to handle them right now. So explicitly disable them in the register accessor, then those fields value will be masked to 0 even if on the hardware the field value is 1. This is safe because from a UAPI point of view that read_sanitised_ftr_reg() doesn't yet return a nonzero value for any of those fields. This will benifit the migration if the host and VM have different values when restoring a VM. Those fields include RNDR_trap, NMI, MTE_frac, GCS, THE, MTEX, DF2, PFAR. Signed-off-by: Shaoqin Huang --- arch/arm64/kvm/sys_regs.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 22b45a15d068..4508288b9d38 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1531,6 +1531,14 @@ static u64 __kvm_read_sanitised_id_reg(const struct = kvm_vcpu *vcpu, val &=3D ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_MTE); =20 val &=3D ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_SME); + val &=3D ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_RNDR_trap); + val &=3D ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_NMI); + val &=3D ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_MTE_frac); + val &=3D ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_GCS); + val &=3D ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_THE); + val &=3D ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_MTEX); + val &=3D ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_DF2); + val &=3D ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_PFAR); break; case SYS_ID_AA64ISAR1_EL1: if (!vcpu_has_ptrauth(vcpu)) --=20 2.40.1