Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3654721pxb; Mon, 24 Jan 2022 14:32:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsQBbOwLSDXJUfZbpTBmctEHHYHImI7x7+eqk8Jpp4JxdbbCFMFhaPy5FnUKa3bTSH79ga X-Received: by 2002:a17:902:aa8f:b0:14a:ccfd:ca42 with SMTP id d15-20020a170902aa8f00b0014accfdca42mr16078189plr.52.1643063578738; Mon, 24 Jan 2022 14:32:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643063578; cv=none; d=google.com; s=arc-20160816; b=rpb4WmwNEvubTg42uOFT9xdiuxYZbiE1NvIV4/t3M1qLQwwDJRw0jd5LhiWCpq2ggH 4btRtQkHHRZgiHfuGOw+m7XpAjqEztl8yHiFbSgf6XOMv42VFQjAROMecOeujaOHdZfO MlE/nLlaMBPyjWg7bGs9CNm9YiJ0FnmJK6znPW/7wx3yQCqh1X3fxPWIWs8potxxQo5H 4gRiOQlIizX+055Cc2K4X7FbPXTRUhQjE7r7aKI6a/B+CLLUegzeMbV8XaHbyNEasowI xRschbG3d2qXx1I/e5SBK65pkkv4H465Y7dzznGUUKZV5I3nY4LtVYrJHa71nb1KjUXG dZhg== 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=OQSUzA6BgYnozlQZsD3grXXG3ELUe+qrYWsJoJAajRA=; b=BKJltCX2VV5HYjf4g8yZUpY655Nnm9AHE17mXgEVBLf8Cv+E0vxydK14f9T6AgjIGF pl0TBkjlWwdjte4lH26/hTaBl9LNzyw/BufK96iofqaCWN4MQw3Scvn3z/f245YFcNK/ +khTN7PJxLKhNtWSSAULR94iOgXhvfC+oMxCbHV2a6Ni+FWKAr2ZC8Hhl6FzJQynqpxe ALq/8omKFlNvF+Xh0Cb0ew9qwi/0WrgCTW2Jw5dXUMyyrc6tFU3TIaUf4julCf88FiZ+ r7VhcLSosl5lTuLpFUEx0lJpK6ZruQGx379LEvKzhGyybcY+TfGmPT1Sgb1kMpTavtj4 RX7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BW+JJHWk; 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 m14si3456011plx.207.2022.01.24.14.32.46; Mon, 24 Jan 2022 14:32:58 -0800 (PST) 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=BW+JJHWk; 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 S1586871AbiAXW11 (ORCPT + 99 others); Mon, 24 Jan 2022 17:27:27 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:45328 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1454428AbiAXVci (ORCPT ); Mon, 24 Jan 2022 16:32:38 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0A1B0B80CCF; Mon, 24 Jan 2022 21:32:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11AD8C340E4; Mon, 24 Jan 2022 21:32:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059956; bh=UMz2txwKo30Dyf7QnStl7t4dAxLp9RmLZ4ZsAfzY8d8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BW+JJHWkvjjwrIo9qMOMbmthLsfS//AexhoedBtm+KjWIjhhclNM4BCG/0cnzjVEp Gabisi7o3EoDcHEm3VVYWkphj3hwvXfcP30EbblGvM/ODe28IqUp2TsWNP9Q0Oj90L 8EdahUkErKbbnufRsU9Jhho7nJusLc6PPTaFnxn0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.16 0790/1039] KVM: VMX: Read Posted Interrupt "control" exactly once per loop iteration Date: Mon, 24 Jan 2022 19:42:59 +0100 Message-Id: <20220124184151.851685870@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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: Sean Christopherson [ Upstream commit cfb0e1306a3790eb055ebf7cdb7b0ee8a23e9b6e ] Use READ_ONCE() when loading the posted interrupt descriptor control field to ensure "old" and "new" have the same base value. If the compiler emits separate loads, and loads into "new" before "old", KVM could theoretically drop the ON bit if it were set between the loads. Fixes: 28b835d60fcc ("KVM: Update Posted-Interrupts Descriptor when vCPU is preempted") Signed-off-by: Sean Christopherson Message-Id: <20211009021236.4122790-27-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/vmx/posted_intr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c index 696ad48ab5daa..46fb83d6a286e 100644 --- a/arch/x86/kvm/vmx/posted_intr.c +++ b/arch/x86/kvm/vmx/posted_intr.c @@ -51,7 +51,7 @@ void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu) /* The full case. */ do { - old.control = new.control = pi_desc->control; + old.control = new.control = READ_ONCE(pi_desc->control); dest = cpu_physical_id(cpu); @@ -104,7 +104,7 @@ static void __pi_post_block(struct kvm_vcpu *vcpu) unsigned int dest; do { - old.control = new.control = pi_desc->control; + old.control = new.control = READ_ONCE(pi_desc->control); WARN(old.nv != POSTED_INTR_WAKEUP_VECTOR, "Wakeup handler not enabled while the VCPU is blocked\n"); @@ -163,7 +163,7 @@ int pi_pre_block(struct kvm_vcpu *vcpu) } do { - old.control = new.control = pi_desc->control; + old.control = new.control = READ_ONCE(pi_desc->control); WARN((pi_desc->sn == 1), "Warning: SN field of posted-interrupts " -- 2.34.1