Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1145212pxv; Fri, 9 Jul 2021 19:26:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCJBssuSpO+IaC/Bu1AGs0KxabO1lKsUdfm7eMdMy5LnuW8Oy0qz5gd9dF6hBlokzBc1xQ X-Received: by 2002:a05:6402:1488:: with SMTP id e8mr26938541edv.341.1625884019677; Fri, 09 Jul 2021 19:26:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884019; cv=none; d=google.com; s=arc-20160816; b=czlchmUDbyt00nXrFN2KRshgEU6WAYb3vkeUva5hn9hCraE6zkJP2NZ/SkUbb+hs0G fPRwL8RJ0byiHVcDPyR5EM8FrFs7wuLQcRfVSWWRtXPzgX3oUbvKhk3OkZeCFE0gb3HA 0LdOKCvcu4rYoIc/092VefwV3OqJg53v1r06iBwcb5ODotlLAPhay5o774Cdct4B0O47 GBCcHvbULIXfdeU7KfpiAPLRO2w1oyFlarw5tIDwFBgX6qFRNIG69EFPIpjGBk2JpiPx eVMb2BlbgPqDI6A0Cvd3N0sIC1kaURei4X8jZaDsvTmZN4c/rMjeXq5HkVJQXbfMCEA3 rBSg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SDyZSIVSYrWHNHqWQm1kV9lDu9LXpgnicaGe31UwmYc=; b=QCS7AC7wDOtJEp/9jYSAys2Vxk2l6nYNikzbjEP8dRRgdjI6KS8NMLJiYijox32Af1 rDPOXlbxqFwE8F4K8XWYwLBzxa8URnHlXFhO50SXyU43xxo8RNtXRuXsJlpKyzpwsgbb OBMGLsGdgHFzrkMZHIjCPIhbAwK4/gwCoxAZc340g3GrxAKjQx586Vk73Q0mzXrIMtFd CwZjFY7ej9usVpd5vOZXEPT/LIgt87M4VX2A7faLyY7j2n3vVRqChmHFxeyOOuldFeu6 03AqN6mkIaXXjXfdsENRG8nPDSTkmu6M4QpZUHhgjLM4gAOu9Do5sa1rXew4S6+q4HNm 6CAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SPk8em0B; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id el10si9075962ejc.429.2021.07.09.19.26.36; Fri, 09 Jul 2021 19:26:59 -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=@kernel.org header.s=k20201202 header.b=SPk8em0B; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233575AbhGJC2C (ORCPT + 99 others); Fri, 9 Jul 2021 22:28:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:42738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233175AbhGJC0j (ORCPT ); Fri, 9 Jul 2021 22:26:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5A9AC613B7; Sat, 10 Jul 2021 02:23:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883833; bh=ZP9KQES+HDuOGeyqR9cpbVw/7pbTbMeag+0gntsBwL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SPk8em0BsH04gOfrzkLe/j5tqfmrZ/J5IZ+yo9jsNduFoAWZM2MoWoYVpaq1DedgJ W+jrJAspUyP77mSrcgYsiK1ughPsYqaopX/pyFlo7SddwBRViunKpCYg5fM+R3mQbz nEuo29IDjFS/te30UKGqWCcyUzUuC2x4vG3OBddEoNKBM8LIfT7/MTa/yiGImpbN2l 1X2gdWe0CveAzWSrVs1XjLfJDXr1qODHmvRgio7ikqT6yn2S0kxsE/nyE9D2/IBbQq 2+nAOdRbW++DAoIcHE5wNXq/C0SV3QTF8IoKUHha+mS5ChcAj6qtCRO87RWpcF0xu3 xLogY/K5IXunQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Heiko Carstens , Vasily Gorbik , Sasha Levin , linux-s390@vger.kernel.org Subject: [PATCH AUTOSEL 5.12 080/104] s390/mem_detect: fix diag260() program check new psw handling Date: Fri, 9 Jul 2021 22:21:32 -0400 Message-Id: <20210710022156.3168825-80-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022156.3168825-1-sashal@kernel.org> References: <20210710022156.3168825-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Heiko Carstens [ Upstream commit 86807f348f418a84970eebb8f9912a7eea16b497 ] The __diag260() inline asm temporarily changes the program check new psw to redirect a potential program check on the diag instruction. Restoring of the program check new psw is done in C code behind the inline asm. This can be problematic, especially if the function is inlined, since the compiler can reorder instructions in such a way that a different instruction, which may result in a program check, might be executed before the program check new psw has been restored. To avoid such a scenario move restoring into the inline asm. For consistency reasons move also saving of the original program check new psw into the inline asm. Signed-off-by: Heiko Carstens Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin --- arch/s390/boot/mem_detect.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/arch/s390/boot/mem_detect.c b/arch/s390/boot/mem_detect.c index 40168e59abd3..3f093556dc3b 100644 --- a/arch/s390/boot/mem_detect.c +++ b/arch/s390/boot/mem_detect.c @@ -69,24 +69,27 @@ static int __diag260(unsigned long rx1, unsigned long rx2) register unsigned long _ry asm("4") = 0x10; /* storage configuration */ int rc = -1; /* fail */ unsigned long reg1, reg2; - psw_t old = S390_lowcore.program_new_psw; + psw_t old; asm volatile( + " mvc 0(16,%[psw_old]),0(%[psw_pgm])\n" " epsw %0,%1\n" - " st %0,%[psw_pgm]\n" - " st %1,%[psw_pgm]+4\n" + " st %0,0(%[psw_pgm])\n" + " st %1,4(%[psw_pgm])\n" " larl %0,1f\n" - " stg %0,%[psw_pgm]+8\n" + " stg %0,8(%[psw_pgm])\n" " diag %[rx],%[ry],0x260\n" " ipm %[rc]\n" " srl %[rc],28\n" - "1:\n" + "1: mvc 0(16,%[psw_pgm]),0(%[psw_old])\n" : "=&d" (reg1), "=&a" (reg2), - [psw_pgm] "=Q" (S390_lowcore.program_new_psw), + "+Q" (S390_lowcore.program_new_psw), + "=Q" (old), [rc] "+&d" (rc), [ry] "+d" (_ry) - : [rx] "d" (_rx1), "d" (_rx2) + : [rx] "d" (_rx1), "d" (_rx2), + [psw_old] "a" (&old), + [psw_pgm] "a" (&S390_lowcore.program_new_psw) : "cc", "memory"); - S390_lowcore.program_new_psw = old; return rc == 0 ? _ry : -1; } -- 2.30.2