From nobody Mon Feb 9 03:30:41 2026 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF4501BD9CE; Mon, 26 Jan 2026 02:48:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769395727; cv=none; b=eIbXowh7Oo3juZlqyRLOansMAo0uIdZjIzlKXgnsYd8NNRu4J6c0CHjqcZmSZFHJNauPv6iHb3Ej5oV4S8MWnfVn0uUKUfkUEpBtzTlD90BOAtpjXmd3RTcSETm6nt+I11Zmu8spqKGzmKEGqLtQrLLSH6hew6WKRdvhxnEomHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769395727; c=relaxed/simple; bh=PjZ8K0McQdNe8F8SMKmXiuTZmYmqd+zIPV/1WD6KVY0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ZkQeCUvcxQ0+ugkSK92Prr7IKUPaJz7i0+9FtByYxsVbR4oTy/ruovnQVGy8sCcffodWe7hNblfFUXfwW142Ai8n21eXwse7jYHoJJWkozdQr6PfPyUkji/FqRUKcuut13CJA5w828ZfTQxja8hPDTsb3D1lcdr8IZs1prMBjP8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn; spf=pass smtp.mailfrom=loongson.cn; arc=none smtp.client-ip=114.242.206.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8DxPMMK1nZpPJcMAA--.41044S3; Mon, 26 Jan 2026 10:48:42 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by front1 (Coremail) with SMTP id qMiowJCx98AJ1nZp+0AxAA--.18313S2; Mon, 26 Jan 2026 10:48:42 +0800 (CST) From: Bibo Mao To: Huacai Chen , WANG Xuerui , Tianrui Zhao Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH v2] LoongArch: KVM: Add more CPUCFG mask bit Date: Mon, 26 Jan 2026 10:48:40 +0800 Message-Id: <20260126024840.2308379-1-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 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-CM-TRANSID: qMiowJCx98AJ1nZp+0AxAA--.18313S2 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== Content-Type: text/plain; charset="utf-8" With LA664 CPU there are more features supported which are indicated in CPUCFG2 bit24:30 and CPUCFG3 bit17 and bit 23. KVM hypervisor can not enable or disable these features and there is no KVM exception when instructions of these features are used in guest mode. Here add more CPUCFG mask support with LA664 CPU type. Signed-off-by: Bibo Mao --- 1. Rebase on the latest version since some common CPUCFG bit macro definitions are merged. 2. Modifiy the comments explaining why it comes from feature detect of host CPU. --- arch/loongarch/kvm/vcpu.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c index 656b954c1134..a9608469fa7a 100644 --- a/arch/loongarch/kvm/vcpu.c +++ b/arch/loongarch/kvm/vcpu.c @@ -652,6 +652,8 @@ static int _kvm_setcsr(struct kvm_vcpu *vcpu, unsigned = int id, u64 val) =20 static int _kvm_get_cpucfg_mask(int id, u64 *v) { + unsigned int config; + if (id < 0 || id >=3D KVM_MAX_CPUCFG_REGS) return -EINVAL; =20 @@ -684,9 +686,22 @@ static int _kvm_get_cpucfg_mask(int id, u64 *v) if (cpu_has_ptw) *v |=3D CPUCFG2_PTW; =20 + /* + * The capability indication of some features are the same + * between host CPU and guest vCPU, and there is no special + * feature detect method with vCPU. Also KVM hypervisor can + * not enable or disable these features. + * + * Here use host CPU detected features for vCPU + */ + config =3D read_cpucfg(LOONGARCH_CPUCFG2); + *v |=3D config & (CPUCFG2_FRECIPE | CPUCFG2_DIV32 | CPUCFG2_LAM_BH); + *v |=3D config & (CPUCFG2_LAMCAS | CPUCFG2_LLACQ_SCREL | CPUCFG2_SCQ); return 0; case LOONGARCH_CPUCFG3: *v =3D GENMASK(16, 0); + config =3D read_cpucfg(LOONGARCH_CPUCFG3); + *v |=3D config & (CPUCFG3_DBAR_HINTS | CPUCFG3_SLDORDER_STA); return 0; case LOONGARCH_CPUCFG4: case LOONGARCH_CPUCFG5: base-commit: 63804fed149a6750ffd28610c5c1c98cce6bd377 --=20 2.39.3