Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp183498rdb; Mon, 15 Jan 2024 17:37:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3+rEUvt1UEITwtvyn+NBRDG65XelWAR//vwOqiY5QxIgUDz8mZ9/WBb1SjXti2B7QwIiP X-Received: by 2002:a17:907:c90:b0:a2c:2071:8633 with SMTP id gi16-20020a1709070c9000b00a2c20718633mr2368523ejc.97.1705369076686; Mon, 15 Jan 2024 17:37:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705369076; cv=none; d=google.com; s=arc-20160816; b=bE0pBGybPqdefYL6iJWoVSyI0973KJs0rMDzD0eAR2d0+SZSl4Ylv7oeQjwIzM6Fi9 77ZmOcqi40Kf//jiBg2tyivF0O4DEl1mXGBVNN/WcBB7F0k3ELmhxVAZoLiazy5JpJgF eDy5UZr9bchDuvgHp7r2aSKKNFGv0trSL6KBWjqMjqewkKXECq3Rohb05THnOOTNl011 odeLzOWLD1VFOne8TZZ3rEKenyG6BF26SOTOBzg7MlvOiGldJFjyknfDzW4s9nfnp4fl 1ZdexwDjEJRHBYqPNjGS1z9aorIdvcEynH6SFFvexSFsibQPaUdPZOpLP4IXBtEa+uvj sZKg== ARC-Message-Signature: i=1; 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Xk4N8R2yVhbSLNHAoMeB4sbkxg/assFl/6iE6xI9zeY=; fh=gIUsPCw9I9wFR7xqxcaz/kvqJnl49o54RCDwNS0JmtU=; b=AN+lymtCXwRw6sP/MJZCIWvrUbwyFQK75EunJVT+cEP/VXKkjWzqrBhC4OCuRUW9jZ HlXBLv1kC0kOODQ1esmpsTyXmEbC54LGbPWUm9c4JPeRZQghMRUGog0VQZt9Zz2D4PQh Af/weC6TBzMehwdqS5eAPCn0AyvHSs/ewjPgqQjr7XNJ7A+CQr0u+4J0x9kroF85QKFp KJShkRFgvzRUKxR3if8Rnb1a1rkTJJWJibdAmtfQxC/nKZFDel9KfhLhod+q9Xp3dGQ/ +v3ON8PIicpJbW2BWn5L4+vmToDL1sKRIL9r+9F1WCqvWp6hY59eBbgox4Wm38PStqxp pn8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KVoyjYKl; spf=pass (google.com: domain of linux-kernel+bounces-26868-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26868-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z25-20020a170906715900b00a2c189debcasi4248369ejj.113.2024.01.15.17.37.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 17:37:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26868-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KVoyjYKl; spf=pass (google.com: domain of linux-kernel+bounces-26868-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26868-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 569D31F23889 for ; Tue, 16 Jan 2024 01:37:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D976228E0E; Tue, 16 Jan 2024 01:07:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KVoyjYKl" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1134D28DCF; Tue, 16 Jan 2024 01:07:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3EA4C43390; Tue, 16 Jan 2024 01:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705367259; bh=ChOl0FJZgyf3XJaJ3pFsNJbkom59E3eYntAJb2B8Hhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KVoyjYKlvSaeEH9Wu8iSCqbIfa+msFawFZZGxZxkOwoNWKf2D3i5nwXLmGXjwPBw2 uW5HpCHNIIBh9NStbT++fGT13LiJ32JCBTaKREM5hE9Vnn/Qo0bkGg5svNtbkAAS3Q iQQTrAf5QGf5HMpuNnvk70h9XOj8MFJFPALB0RbeZrEyMoLlM+MBvjb7bljdWEc+xG TotjbS+/6xAw6IAgAdliUZzzh6ITMD11lnSSGnzfqtRTseNdG3RdArVrwwoZeaJ7Hk 3z19dDuYAjFS2koRSs9mPwF+LVYaQe+kIJJqQTM7v57I6vmB7f39S5QAz9pn4sqaDb sYFzI/45KqjXg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , Sasha Levin , frankja@linux.ibm.com, gor@linux.ibm.com, kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 04/11] KVM: s390: fix setting of fpc register Date: Mon, 15 Jan 2024 20:07:04 -0500 Message-ID: <20240116010729.219219-4-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240116010729.219219-1-sashal@kernel.org> References: <20240116010729.219219-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.147 Content-Transfer-Encoding: 8bit From: Heiko Carstens [ Upstream commit b988b1bb0053c0dcd26187d29ef07566a565cf55 ] kvm_arch_vcpu_ioctl_set_fpu() allows to set the floating point control (fpc) register of a guest cpu. The new value is tested for validity by temporarily loading it into the fpc register. This may lead to corruption of the fpc register of the host process: if an interrupt happens while the value is temporarily loaded into the fpc register, and within interrupt context floating point or vector registers are used, the current fp/vx registers are saved with save_fpu_regs() assuming they belong to user space and will be loaded into fp/vx registers when returning to user space. test_fp_ctl() restores the original user space / host process fpc register value, however it will be discarded, when returning to user space. In result the host process will incorrectly continue to run with the value that was supposed to be used for a guest cpu. Fix this by simply removing the test. There is another test right before the SIE context is entered which will handles invalid values. This results in a change of behaviour: invalid values will now be accepted instead of that the ioctl fails with -EINVAL. This seems to be acceptable, given that this interface is most likely not used anymore, and this is in addition the same behaviour implemented with the memory mapped interface (replace invalid values with zero) - see sync_regs() in kvm-s390.c. Reviewed-by: Christian Borntraeger Reviewed-by: Claudio Imbrenda Signed-off-by: Heiko Carstens Signed-off-by: Alexander Gordeev Signed-off-by: Sasha Levin --- arch/s390/kvm/kvm-s390.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index eb97db59b236..5526f782249c 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -3700,10 +3700,6 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) vcpu_load(vcpu); - if (test_fp_ctl(fpu->fpc)) { - ret = -EINVAL; - goto out; - } vcpu->run->s.regs.fpc = fpu->fpc; if (MACHINE_HAS_VX) convert_fp_to_vx((__vector128 *) vcpu->run->s.regs.vrs, @@ -3711,7 +3707,6 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) else memcpy(vcpu->run->s.regs.fprs, &fpu->fprs, sizeof(fpu->fprs)); -out: vcpu_put(vcpu); return ret; } -- 2.43.0