Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp933534lqc; Fri, 8 Mar 2024 17:11:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXwr0Y3HteO7ciEW6os26rn5v4sC3WiVueUfQADdY60KYTHS1TCawdFO5mcW4hiu1gbBf5Z7UAYVZ+fa0lRx+UCkUN6rwx38/OsLSgVbg== X-Google-Smtp-Source: AGHT+IFIc7NnSrIduusgCq9p+VQFjmAFZ921v125E0aX9BibHBxweErix5IKkKixPI9z/YAPlXKF X-Received: by 2002:a17:902:c181:b0:1dc:8f19:8344 with SMTP id d1-20020a170902c18100b001dc8f198344mr382157pld.27.1709946688273; Fri, 08 Mar 2024 17:11:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709946688; cv=pass; d=google.com; s=arc-20160816; b=T/y5rOnWcnwiUD4q4gHWrz7teMXwu0562j477ElJHEXGNeGvW9MFbBHgHxAV/43Zl7 hu/V6nkxY2X1HtK2WhLVHqlzVeyqdeCP1oIYfEIjZc6lyc9ofrZzSz8lsoch8/xA59jT a9GTeb2gZivNmfAejA5depwk3NKISuN5jZ47JxJD3W1nahIFo82pUzGx5mSeTa2e4Ool keVzpbYM2Y6NOc3Xrg2r/FJKngxAfkO1x29zvvd8+BceaedVUlCsupuyJCxPs+xAA8F2 KWmgLuRl8e3vWX1tMa341LeiCfKtihKTAo7cowGEl21hASnCOm6hjCGYRPSX174CGgVv FBgA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=opv/pkYi5ZzIQaSkE1dFeCV7eMElrF9Hr2aQKt+M0LM=; fh=C4+XMGNz9ds/fcOeEk8C1dOUni9+id9GTifTOuMvImI=; b=PtLOVQkSqbygzbxKZC+XELXxpWAcp0ZGU9ThKKDRX77R1rhMYNAboRnDtFh4hRf3eY j8yfkTQLBJgLk2Si1ONEtxQps6Qft0JJvKeGEkSYiwSmp+xKhAMc9fj3b/AsNoqf2b2c ZcpfqhQCs9j1MqlfSfLOLCR0aQAxKG1S8iuE/7PvKULSZR9OvNcT8mR1ddN3JZyEDmpT LbtXYRT7p24zZMyzw21hrYo9FI0cSMuTBNv82aIZ46lRsVKLop7x+4P15RtDEBvte1z2 ajsbZlbjpFaGrfTsIg3QJyUjFgHHs2L7YLJURMhKevH8Hf2W6k1aHBK/5E2IpZQwsE7n eKoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=sY2Wr5fp; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-97722-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97722-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e7-20020a170902784700b001dd526ff7casi478257pln.438.2024.03.08.17.11.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 17:11:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97722-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=sY2Wr5fp; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-97722-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97722-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EEC3C281DF2 for ; Sat, 9 Mar 2024 01:11:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 34D8C28E09; Sat, 9 Mar 2024 01:09:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sY2Wr5fp" Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 920401EB46 for ; Sat, 9 Mar 2024 01:09:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709946591; cv=none; b=BzClrI+lwUTz1Ejtl83ORXueqKnOdjPPYf4bl82x2JB+m/RNBNpn4XzXHITJ6VGCF7ZZpmxGJmoViLZAR1O40YgGM1frcv/EJSHGy0kDdbyPgpPpzObnpm23f9wcDOm47fRpNGqY3bHaUJK42aj25+fT/tFWlixss2SzVoVJiWU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709946591; c=relaxed/simple; bh=j5KgXER4nINsShPo8aYOrG+wphwo2SK+yLSChO3NEJA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=FC3V9BaTxe6RE0JK/014/JOhxE+MiJAI+rQvEU9iKHkkoviScNwEZIXgymqeJQtg7NqrSHBqILF5K2lkD9tkjMNnvoExtB2El3wqvKtFYbQuC3DS5jiAbq5D+0VhcaOqh8C5MVA0qw1gijXGnYbHmRJwwsiJsexD5MySAZUp00E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=sY2Wr5fp; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-6e67b55e508so26193b3a.0 for ; Fri, 08 Mar 2024 17:09:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709946588; x=1710551388; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=opv/pkYi5ZzIQaSkE1dFeCV7eMElrF9Hr2aQKt+M0LM=; b=sY2Wr5fpg09RPtdj9bLKU8/33TfK9+4kvMkg+yjdPXkBUOAGFSFwROK/zC3s1MaL5z DccWlFXW+bv30XCRIJI3T9WwVUNzT/i4gEKDrIn3WiGvPqUx+Q/u0KrgIlFtkHD26/n+ iBi2U1gxZD19BXWxqQYpCEYxA+CEnsthMty2FBd/yYK/0mWSfQ+AKDHlefDP1W1rEqta IL5+m2rzJE8VqEiY41Cuwrtv5CmmUaDeYD7cy3scFSI7cuIuREvtoAw6WNhrwlnNURT1 jncNtTiLsnVh4uMa9LsptlRB+fePoL32YC2kMAs1yzfVi359kwFgktidNQAdgnr6O+9c z+tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709946588; x=1710551388; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=opv/pkYi5ZzIQaSkE1dFeCV7eMElrF9Hr2aQKt+M0LM=; b=N3NfmVOxnBnDiylH69ypxlTmbFjhas4Qi3WQW3oqh2bwz+/mbnFfRdI+Ws0y4rCvSo 9RZzk+9DASpGXYyIFtumhstECVmTbVsIpeo+vz6YKhntw4VLjj00I2Gsvr3huBDyFehM W+TyQoEIwO7DeneE+qeb2TZ2aiyhDXeQghL+apdEgWIS49KUE1amA3nQU3eEMLO1hJ3v 4VjgACb/7AwGsIy8n9OdnzB1CxJHUTv7FvQZR/MsebI0uDJkc7MXo9gRLK66zey9AusC mY6YniYZ94NT69ClFPCiolbMdnUxUWe20IdyQT3udBMDRfpVSC6BnMvrEWncvdcWz35r clOg== X-Forwarded-Encrypted: i=1; AJvYcCX1ndFNcTEgzs3F+KDNgvRkHcYv7/klWz+xb7BZkY1FifyQp1z+QuQmgDb95tLiNJYol/PtuDkLq07gDH05t6RPx8VSj2uo54ydqAfV X-Gm-Message-State: AOJu0Yw6tH3PHqk0/TQ/OlXQiHm7JjFMM4QztU4ySM/Sh8DLEeJ8WjV3 yJff4DQz3FIw28s2oHpJ7u+2sfxpuuc0WowqPasdqtgE0wXAnAm7yEI7zJWI7FW/bJPoybS+oEW cGQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:2291:b0:6e6:4f0a:422 with SMTP id f17-20020a056a00229100b006e64f0a0422mr38978pfe.6.1709946588027; Fri, 08 Mar 2024 17:09:48 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 8 Mar 2024 17:09:28 -0800 In-Reply-To: <20240309010929.1403984-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240309010929.1403984-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Message-ID: <20240309010929.1403984-5-seanjc@google.com> Subject: [PATCH 4/5] KVM: x86: Ensure a full memory barrier is emitted in the VM-Exit path From: Sean Christopherson To: Paolo Bonzini , Sean Christopherson , Lai Jiangshan , "Paul E. McKenney" , Josh Triplett Cc: kvm@vger.kernel.org, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Kevin Tian , Yan Zhao , Yiwei Zhang Content-Type: text/plain; charset="UTF-8" From: Yan Zhao Ensure a full memory barrier is emitted in the VM-Exit path, as a full barrier is required on Intel CPUs to evict WC buffers. This will allow unconditionally honoring guest PAT on Intel CPUs that support self-snoop. As srcu_read_lock() is always called in the VM-Exit path and it internally has a smp_mb(), call smp_mb__after_srcu_read_lock() to avoid adding a second fence and make sure smp_mb() is called without dependency on implementation details of srcu_read_lock(). Cc: Paolo Bonzini Cc: Sean Christopherson Cc: Kevin Tian Signed-off-by: Yan Zhao [sean: massage changelog] Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 276ae56dd888..69e815df1699 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -11082,6 +11082,12 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) kvm_vcpu_srcu_read_lock(vcpu); + /* + * Call this to ensure WC buffers in guest are evicted after each VM + * Exit, so that the evicted WC writes can be snooped across all cpus + */ + smp_mb__after_srcu_read_lock(); + /* * Profile KVM exit RIPs: */ -- 2.44.0.278.ge034bb2e1d-goog