Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp310098pxj; Thu, 20 May 2021 09:49:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOe6UOi7VonRGbSdA2HdybCYfCkhhFwV7H15o7i/Sq2NUDDV+mIaJsG5rVXIUH508CKbGu X-Received: by 2002:aa7:dc17:: with SMTP id b23mr5892389edu.359.1621529376500; Thu, 20 May 2021 09:49:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621529376; cv=none; d=google.com; s=arc-20160816; b=pN0jeQ4ITe+Zb4Yg/AyQ5Ey5Xm3yIA6INsd7DLwjxJFK6vMkLATUpFg/orjOP4WQgn yVtgafOu3eDjp1Z8lBP0YpRt6zEefzfQ4Xh093xjWJVzgTdw5eomK3dCF+G5EAFz3cMB tbTYjXtK9eT2VpA4qkl+NdrTyhjAkeUhWKVCEYBTPVzqBS0J0Zi0gjsbt8ZXFiTejDDj 5zMzvXFvn1HyAOJO581SkVsZJgE7xwUXatXHItwGyIUIlETyiLQOQrwXkUYrJh8Afk8S P63COzZCOvNWKFulNaGj5qF08+pWLN3tEZCz5q8+HRAtDp8LebRJunk60kdIsb1VdOxo Q4jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=g0ftORaEcoPplyGr8iSxYzywMg9gcbiUPo4H0V8dmAw=; b=DDhp3eVz+2QyBiCHPpeO8wHgPrnow4W2o2z0nZaxVf7yhLORThcLm/x6dCVfwoi89z eQBRCKPx6yZ5d5oCUdHtBQ+donEoSCMs+0I3JrVpTO/zQHDBsHxlV94f8xAfsQZDCxqi hUYv7wYy+UKdkeLTJGkOlPxGdgWZwzIVj8JHdi7ylhjINITfP/GOPfLMYk89HZxcEVpu oID7qhItrjUiQ6jHYf2dpaM+eIpIEUD8v+F12+9Ky1FYRMlk/exirewzwKGrU/kmo99a SHtHs8WMPcFuSmDUNBsWpfy4lJvQgtj9neuh6UM+VmFPyU+xD+mf8FGTBDuxuJpbvTH+ Iihw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aoA8YofX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zg9si3381381ejb.426.2021.05.20.09.49.12; Thu, 20 May 2021 09:49:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aoA8YofX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234445AbhETJvy (ORCPT + 99 others); Thu, 20 May 2021 05:51:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:52778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233993AbhETJtC (ORCPT ); Thu, 20 May 2021 05:49:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4E00E61358; Thu, 20 May 2021 09:34:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503296; bh=ZNFqcPHsVlDP099oWQK5aZnB2x+SN6vZ7XCZVSW9lGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aoA8YofXrzP+5M9IpovkzhHEdJ0sQF2VirN89LyC+eWUy99sKwCWuZicWZ7wHtkNy OPEYm7WJZh5vtJi3f5K/xjyA3qiuP1hWXkdfVD1+UaeQYNu7+IJfcShtb33EpUGkYZ Myev+ulen8t5ygsrgAMMfbIYGnxpxFFdpQoggENs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heiko Carstens , Christian Borntraeger , David Hildenbrand , Janosch Frank , Cornelia Huck Subject: [PATCH 4.19 158/425] KVM: s390: fix guarded storage control register handling Date: Thu, 20 May 2021 11:18:47 +0200 Message-Id: <20210520092136.643894124@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Heiko Carstens commit 44bada28219031f9e8e86b84460606efa57b871e upstream. store_regs_fmt2() has an ordering problem: first the guarded storage facility is enabled on the local cpu, then preemption disabled, and then the STGSC (store guarded storage controls) instruction is executed. If the process gets scheduled away between enabling the guarded storage facility and before preemption is disabled, this might lead to a special operation exception and therefore kernel crash as soon as the process is scheduled back and the STGSC instruction is executed. Fixes: 4e0b1ab72b8a ("KVM: s390: gs support for kvm guests") Signed-off-by: Heiko Carstens Reviewed-by: Christian Borntraeger Reviewed-by: David Hildenbrand Reviewed-by: Janosch Frank Reviewed-by: Cornelia Huck Cc: # 4.12 Link: https://lore.kernel.org/r/20210415080127.1061275-1-hca@linux.ibm.com Signed-off-by: Christian Borntraeger Signed-off-by: Greg Kroah-Hartman --- arch/s390/kvm/kvm-s390.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -3624,16 +3624,16 @@ static void store_regs(struct kvm_vcpu * current->thread.fpu.fpc = vcpu->arch.host_fpregs.fpc; current->thread.fpu.regs = vcpu->arch.host_fpregs.regs; if (MACHINE_HAS_GS) { + preempt_disable(); __ctl_set_bit(2, 4); if (vcpu->arch.gs_enabled) save_gs_cb(current->thread.gs_cb); - preempt_disable(); current->thread.gs_cb = vcpu->arch.host_gscb; restore_gs_cb(vcpu->arch.host_gscb); - preempt_enable(); if (!vcpu->arch.host_gscb) __ctl_clear_bit(2, 4); vcpu->arch.host_gscb = NULL; + preempt_enable(); } /* SIE will save etoken directly into SDNX and therefore kvm_run */ }