Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1147172pxv; Fri, 9 Jul 2021 19:30:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz42Uf2U+Hn46cLittfL4JWlEtoZIQ/z86BbD0lKXcwTucx2p0NXQiuOEpa5TAnDwsB0hpS X-Received: by 2002:a17:906:24c3:: with SMTP id f3mr28455465ejb.145.1625884255349; Fri, 09 Jul 2021 19:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884255; cv=none; d=google.com; s=arc-20160816; b=ssFRC4Kr0mpQJPECiCPgMzhPQPFPV+7Z/F7H9fZ9Cbh3wqkFbuCUSaIPXBg6Ty1Zs5 NLtwfWj3oAu4W7NJkC25n306eKs3ZEScR6xA1JTVJpPopxGaAMVPawmyNNv3AY1kx15O Wy4+kPxUdXkSnLT3HAxoIQs0LiM1pZ4M2Ld1do2OZWiPGFRQt2kkvGh28mf5k3xDFWPb a9vePCoPQA849wYgBuC23fEXsHzOwUqlEWQ9tQvOQaHYiykv1LBA9lcuA+ma6uRxITw2 q5H85wOeC2eCn5mX5++10PSKAVASDjpescOqrHLvdIr+IJKXENXuwGG+3ib0IAhU1fBj gb1g== 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=kBGSxRLyp1PfepqNe0qPxKEDu3QHrWH28BIOEalgko0=; b=EI1KZlLbTny5Xh3lCWtxYsguPAYa3ZYg0KgRdyHnTxt9+xo0uSfK1ejApjXYykuD0N Z0IikY5z+taYGTZjEjXADjqYOK+BWrX+FA99qD/43zHMZWonaeXROxn6qrnyixgrEd1d bdjli/V4BTK4mET5Gad2mW3yNvr0pK34UWZh31wHJlWe6oK3fWBfazD3wkKs9wW0wARC oHYzvlp9zHlsHWIt09y/cB9UYhzSbMQwbZktR1naZOLnGM4+K39xRadUzx0fWCWsJjxI Gz59n4DUBqBQPOIMWdC/uuycul2b3hW84yLQGbw8lo9gyePlfxpYknLzYiN/FmRAw7+r uAJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=si+05z4k; 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 hs19si9507684ejc.676.2021.07.09.19.30.32; Fri, 09 Jul 2021 19:30:55 -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=si+05z4k; 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 S233991AbhGJCc0 (ORCPT + 99 others); Fri, 9 Jul 2021 22:32:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:43262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234474AbhGJC32 (ORCPT ); Fri, 9 Jul 2021 22:29:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1520A61409; Sat, 10 Jul 2021 02:26:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883994; bh=gfmQPhuheg6CmzwqvqF1tZkKqQBYwpU926EpPpZX7Ws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=si+05z4kM9U/vP7FtMtbxOx15Z6tvtPzI2gYNnbsWYZPTtF6zC6NzJlFGaqy2qF2Y XKjTlDsEZGy3on9YTAXOofH1bUNzjIKFDv99c6Rwz0x5whlhFFQ/bMjA017A7vaucM NdvnE9GmEC/Tp8OznuOzKILI+m02IGCMwSCfGRfFa/IUiz9Ydf/7IWYryUUSy36nZg 89/CjOEUjV393eZoFVIvwgzgUi6T3MW2wHI770Z+R6v0IDVjGLYIA57jMkW62lza/7 5UjYLDY4xDRqQO1uLBZqMc+fIlhv4AkdWZt5W1Bjr+vEEhl6gbEv85TRp5Eqz6/ts/ 8Ra+fCQd5DvkQ== 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.10 70/93] s390/ipl_parm: fix program check new psw handling Date: Fri, 9 Jul 2021 22:24:04 -0400 Message-Id: <20210710022428.3169839-70-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022428.3169839-1-sashal@kernel.org> References: <20210710022428.3169839-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 88c2510cecb7e2b518e3c4fdf3cf0e13ebe9377c ] The __diag308() 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/ipl_parm.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/arch/s390/boot/ipl_parm.c b/arch/s390/boot/ipl_parm.c index f94b91d72620..c56bbf58a945 100644 --- a/arch/s390/boot/ipl_parm.c +++ b/arch/s390/boot/ipl_parm.c @@ -28,22 +28,25 @@ static inline int __diag308(unsigned long subcode, void *addr) register unsigned long _addr asm("0") = (unsigned long)addr; register unsigned long _rc asm("1") = 0; 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 %[addr],%[subcode],0x308\n" - "1: nopr %%r7\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), [addr] "+d" (_addr), "+d" (_rc) - : [subcode] "d" (subcode) + : [subcode] "d" (subcode), + [psw_old] "a" (&old), + [psw_pgm] "a" (&S390_lowcore.program_new_psw) : "cc", "memory"); - S390_lowcore.program_new_psw = old; return _rc; } -- 2.30.2