From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Heiko Carstens <hca@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Sasha Levin <sashal@kernel.org>,
frankja@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com,
kvm@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [PATCH AUTOSEL 5.15 18/24] KVM: s390: interrupt: use READ_ONCE() before cmpxchg()
Date: Mon, 16 Jan 2023 09:03:53 -0500 [thread overview]
Message-ID: <20230116140359.115716-18-sashal@kernel.org> (raw)
In-Reply-To: <20230116140359.115716-1-sashal@kernel.org>
From: Heiko Carstens <hca@linux.ibm.com>
[ Upstream commit 42400d99e9f0728c17240edb9645637ead40f6b9 ]
Use READ_ONCE() before cmpxchg() to prevent that the compiler generates
code that fetches the to be compared old value several times from memory.
Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Link: https://lore.kernel.org/r/20230109145456.2895385-1-hca@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kvm/interrupt.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index 8ce03a5ca863..ca7d09f09809 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -81,8 +81,9 @@ static int sca_inject_ext_call(struct kvm_vcpu *vcpu, int src_id)
struct esca_block *sca = vcpu->kvm->arch.sca;
union esca_sigp_ctrl *sigp_ctrl =
&(sca->cpu[vcpu->vcpu_id].sigp_ctrl);
- union esca_sigp_ctrl new_val = {0}, old_val = *sigp_ctrl;
+ union esca_sigp_ctrl new_val = {0}, old_val;
+ old_val = READ_ONCE(*sigp_ctrl);
new_val.scn = src_id;
new_val.c = 1;
old_val.c = 0;
@@ -93,8 +94,9 @@ static int sca_inject_ext_call(struct kvm_vcpu *vcpu, int src_id)
struct bsca_block *sca = vcpu->kvm->arch.sca;
union bsca_sigp_ctrl *sigp_ctrl =
&(sca->cpu[vcpu->vcpu_id].sigp_ctrl);
- union bsca_sigp_ctrl new_val = {0}, old_val = *sigp_ctrl;
+ union bsca_sigp_ctrl new_val = {0}, old_val;
+ old_val = READ_ONCE(*sigp_ctrl);
new_val.scn = src_id;
new_val.c = 1;
old_val.c = 0;
@@ -124,16 +126,18 @@ static void sca_clear_ext_call(struct kvm_vcpu *vcpu)
struct esca_block *sca = vcpu->kvm->arch.sca;
union esca_sigp_ctrl *sigp_ctrl =
&(sca->cpu[vcpu->vcpu_id].sigp_ctrl);
- union esca_sigp_ctrl old = *sigp_ctrl;
+ union esca_sigp_ctrl old;
+ old = READ_ONCE(*sigp_ctrl);
expect = old.value;
rc = cmpxchg(&sigp_ctrl->value, old.value, 0);
} else {
struct bsca_block *sca = vcpu->kvm->arch.sca;
union bsca_sigp_ctrl *sigp_ctrl =
&(sca->cpu[vcpu->vcpu_id].sigp_ctrl);
- union bsca_sigp_ctrl old = *sigp_ctrl;
+ union bsca_sigp_ctrl old;
+ old = READ_ONCE(*sigp_ctrl);
expect = old.value;
rc = cmpxchg(&sigp_ctrl->value, old.value, 0);
}
--
2.35.1
next prev parent reply other threads:[~2023-01-16 14:12 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-16 14:03 [PATCH AUTOSEL 5.15 01/24] scsi: iscsi: Fix multiple iSCSI session unbind events sent to userspace Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 02/24] cpufreq: Add Tegra234 to cpufreq-dt-platdev blocklist Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 03/24] kcsan: test: don't put the expect array on the stack Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 04/24] cpufreq: Add SM6375 to cpufreq-dt-platdev blocklist Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 05/24] ASoC: fsl_micfil: Correct the number of steps on SX controls Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 06/24] net: usb: cdc_ether: add support for Thales Cinterion PLS62-W modem Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 07/24] drm: Add orientation quirk for Lenovo ideapad D330-10IGL Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 08/24] s390/debug: add _ASM_S390_ prefix to header guard Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 09/24] s390: expicitly align _edata and _end symbols on page boundary Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 10/24] perf/x86/msr: Add Emerald Rapids Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 11/24] perf/x86/intel/uncore: " Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 12/24] arm64/mm: Define dummy pud_user_exec() when using 2-level page-table Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 13/24] cpufreq: armada-37xx: stop using 0 as NULL pointer Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 14/24] ASoC: fsl_ssi: Rename AC'97 streams to avoid collisions with AC'97 CODEC Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 15/24] ASoC: fsl-asoc-card: Fix naming of AC'97 CODEC widgets Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 16/24] spi: spidev: fix a race condition when accessing spidev->spi Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 17/24] spi: spidev: remove debug messages that access spidev->spi without locking Sasha Levin
2023-01-16 14:03 ` Sasha Levin [this message]
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 19/24] scsi: hisi_sas: Set a port invalid only if there are no devices attached when refreshing port id Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 20/24] r8152: add vendor/device ID pair for Microsoft Devkit Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 21/24] platform/x86: touchscreen_dmi: Add info for the CSL Panther Tab HD Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 22/24] platform/x86: asus-nb-wmi: Add alternate mapping for KEY_SCREENLOCK Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 23/24] lockref: stop doing cpu_relax in the cmpxchg loop Sasha Levin
2023-01-16 14:03 ` [PATCH AUTOSEL 5.15 24/24] firmware: coreboot: Check size of table entry and use flex-array Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230116140359.115716-18-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox