From patchwork Wed Feb 14 10:15:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: WANG Xuerui X-Patchwork-Id: 20363 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1118856dyb; Wed, 14 Feb 2024 02:35:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWsoQh2nbe35ovnjc9MorUT+kikL1TcGAHHx3qhdd2yZWLNaQgzzTBFa+ZdJ5NSLb7mcO1GgBVbA+boU7oWND/8PbXx1w== X-Google-Smtp-Source: AGHT+IEivnYesQIktsLX5UTk9BSCpIligRB5g5Y9iPionTVilQQmebpNQdtbbDc7MLVpskpffmAB X-Received: by 2002:a05:6214:5681:b0:68e:fa66:d04c with SMTP id qm1-20020a056214568100b0068efa66d04cmr3055235qvb.55.1707906908337; Wed, 14 Feb 2024 02:35:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707906908; cv=pass; d=google.com; s=arc-20160816; b=DSTINK9F5gc3gBcCjJiebsqwTpBz3pPNz+/4CDfUEQ45SzoUKQk3XFL5ePV2wMll5n Xo2PyVivxRj9yR2+CXI6CGjgy5+kqkOLMRljjHQ/ZNPzWwteqAJaHAcqoxvmNBPpxEN8 MIewONHhKxj2hscRy+FLlkCiPnGwvVI2wWQD0VUwXvx2lMICKSzlBGhJBzOFwWBaZEGg w9y/ZNADO22DwzNSKaQACr3NnWBxwMLNF9aHX3YR6Qii0a0P9F03Mp0xUScoV090pXvc kEqJnbXrGTWB7uKH9S7CwjaJ9yXif+9Jb/5KAjiTLynS/2bgZShEN1hNzADW/V43xFaJ SYaw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=0/EBvHwt6rh8zanY5Zj96HbEZ6xogD2wLNOtqU7DC3E=; fh=bnX4016cMVG5PsvTZIZCRnM0Rr+/0yfwEXIFaBL24hU=; b=Yg7X7Qp3AVWniQUDv/lYiTSPs2zecVhsy1u6n+VWrxFArr215/vzPTLDSTB9X12gjf +R/Yc1rulRSX9FRQ79k/RIx08Tok2vHVuLKGuBZyJX6lkeswP1ORyTUxnujZKiOEepXZ MZgNYfrvSR7caLx7KutAoIpuxVKDGixsLNXYJPMITJZo6rN2lkn0RnWxLEpjZ74eHcSX a46STAzX8P/9igjDk82AcIxwfr62zQr8305y8PxgLoG07nctvMPOtZ45JiCl4P/u4EJ6 kwT9esWxdX0E54IhAG8ERbQzDT+dXwWOwyR1kx6fEvzZ7tRcdMz1PF46yNI3XF/JaCcI fSgg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=setR4T+X; arc=pass (i=1 spf=pass spfdomain=xen0n.name dkim=pass dkdomain=xen0n.name); spf=pass (google.com: domain of linux-kernel+bounces-65043-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65043-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCUyhZ0oUgJEqWQcAIt6OGAHFciAJh7tdD0Ojpnjg/mhJ5Bb+P4KmhtO4qxsINt2fog27CP828QUE6rzncJW0wrmvSXskQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id e4-20020a0562140d8400b0068cd43d6de7si4794613qve.455.2024.02.14.02.35.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 02:35:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65043-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=setR4T+X; arc=pass (i=1 spf=pass spfdomain=xen0n.name dkim=pass dkdomain=xen0n.name); spf=pass (google.com: domain of linux-kernel+bounces-65043-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65043-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 413BC1C27690 for ; Wed, 14 Feb 2024 10:25:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ADA051B814; Wed, 14 Feb 2024 10:24:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xen0n.name header.i=@xen0n.name header.b="setR4T+X" Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) (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 69F2017552; Wed, 14 Feb 2024 10:24:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.28.160.31 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707906251; cv=none; b=FbII5D2SEfNdiGMw8wURJyA7EPZzHSBpIw6CsY7V6jyOxJr3Z3h59U+NB9tS3wSXuXEunN41kzxF0V35mKE1e04K0U5q5yraDIImUPQgnEFFmiJZi7gxe86lsTgzQAxliVdr9w9l5wF/BalMtXBCnxFP5lB/RVGg9K/31lLXNzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707906251; c=relaxed/simple; bh=gifFn/80q51+NK0CjT7eHBD5A+SqG4W3WFxbem4VjfA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=HqElN2S9Wr8MWwk2nrx82w2Fug2zKePsEJDNDqC91V2a0bePuynBgghPxrnMpsqktI4qNQp+R6D1n8zaU04R8c5BIij/AGZIucZPwqpqg/51Ihcj20+TaNdVadsHdllRrQvOr8bqc/fBYG7SPnCBPAkaghTliNkWNI/IT6w28iQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xen0n.name; spf=pass smtp.mailfrom=xen0n.name; dkim=pass (1024-bit key) header.d=xen0n.name header.i=@xen0n.name header.b=setR4T+X; arc=none smtp.client-ip=115.28.160.31 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xen0n.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xen0n.name DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1707905763; bh=gifFn/80q51+NK0CjT7eHBD5A+SqG4W3WFxbem4VjfA=; h=From:To:Cc:Subject:Date:From; b=setR4T+XzQd+3Dsb6NQLwydEUmMUGSRoZZycHQcZWdsRvKwvSeUFhltRAqC8Tu/d4 JlDB2Fq+yZigcUGrViMvQ8GQNkH6Ii3vC8mZWlN0/NDM2P7NFUbXnuRxu6Thd4CRSM dISIPx2Jaj9zrsxwmoXM3zpWWLJfDEVow5GeGusY= Received: from ld50.lan (unknown [IPv6:240e:388:8d00:6500:5531:eef6:1274:cebe]) (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 mailbox.box.xen0n.name (Postfix) with ESMTPSA id 8312C600CF; Wed, 14 Feb 2024 18:16:02 +0800 (CST) From: WANG Xuerui To: Paolo Bonzini , Huacai Chen Cc: Tianrui Zhao , Bibo Mao , kvm@vger.kernel.org, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, WANG Xuerui Subject: [PATCH for-6.8 0/5] KVM: LoongArch: Fix wrong CPUCFG ID handling Date: Wed, 14 Feb 2024 18:15:52 +0800 Message-ID: <20240214101557.2900512-1-kernel@xen0n.name> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790870194464462907 X-GMAIL-MSGID: 1790870194464462907 From: WANG Xuerui Hi, While trying to add loongarch to the Rust kvm-bindings crate, I accidentally discovered faulty logic in the handling of CPUCFG IDs ("leaves" for those more familiar with x86), that could result in incorrectly accepting every possible int for the ID; fortunately it is 6.8 material that hasn't seen a release yet, so a fix is possible. The first two patches contain the fix, while the rest are general drive-by refactoring and comment cleanups. (As it is currently the Chinese holiday season, it is probably best for this series to go through the kvm tree, instead of the loongarch one even though they seem to like prefer collecting every loongarch patch.) WANG Xuerui (5): KVM: LoongArch: Fix input value checking of _kvm_get_cpucfg KVM: LoongArch: Fix kvm_check_cpucfg incorrectly accepting bad CPUCFG IDs KVM: LoongArch: Rename _kvm_get_cpucfg to _kvm_get_cpucfg_mask KVM: LoongArch: Streamline control flow of kvm_check_cpucfg KVM: LoongArch: Clean up comments of _kvm_get_cpucfg_mask and kvm_check_cpucfg arch/loongarch/kvm/vcpu.c | 72 ++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 43 deletions(-)