Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp68791lqp; Tue, 21 May 2024 18:58:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXRebN7KA+XXG36zD/n0fZGckZ2kOOU6zXKk6bWjCJP9geTXhu1vb7RXRoYjWudy6WnQaFYsQlgXrDabltobdCdRVZhSRjMJEhNjMFM2w== X-Google-Smtp-Source: AGHT+IH2BiRhzfs+rKINKPWj21jCgrUotdy8m828qoPUj7F1ZMTk51XGuOBXIeqRyre2mkSCC2jF X-Received: by 2002:a17:903:2281:b0:1f2:fdf2:b6e5 with SMTP id d9443c01a7336-1f2fdf2bb60mr108864305ad.9.1716343119157; Tue, 21 May 2024 18:58:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716343119; cv=pass; d=google.com; s=arc-20160816; b=ZzHnQAARuV+R5c3yWTys6HIuNZgI+LV7TASEZYMUOddYMyPJcgbXg/i95+GZthZNM3 PCV/w6v7QGRzPb9pBWEL4nYWQdiOAUpXFagIvEowBsbO501RL0a5xzFs4ovybYRViz5g 9wIGs8MmL9Y7/RKiTlukocfIG0D+NvP4uztwe+JmMsc/ZqX8E7YAGa3q9tpDaMtjS4aI xmfAyHaGexl8+aeoguCgvICGL1Ndtw9gO6XnlQxsf2MYCEXkHt+gZKxAcRLNz8kF95Dd v2OITlW0kmwb7yUmkLzi19N0Zkbr+JXTs03JcfuT38lJfCk2WOPMieyLNpF5WtsUNps0 1eAw== 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=N3tcdNqgpk0g0Qawt6D2SIU8FL4Y9j5vsBcc8xUlRY4=; fh=benrnQMum/JAW83MwDQ7LZlH3t4MyoQUu0xawBMlo3M=; b=q5pB649fW0SC2k74YjO0P3mlsD7Qw9gifrRlL+A1ChD1xAv92FDURT/RRNTonogYDD LxlVIPG8jAzvCcWMhtx3D7Ok6nLOYppQf+iRot+oOw/rNEEQ8b9EFDoOwG5aKRuf6tcg b/C6KeIaAolbkh/NT/rS5wtBD4vE+NBB/u5TZud/uA/ywixrzxU8N73M4qtfMF1rU5a1 +OEFO/c1eulnvUtwEoeufofrl5qr5/PG1tVbdqelpTmirD/39CdWPdPYOx8dltYBdfBh o/y6i1UNEnjSvte3ntnbe7KClfP2C4j33B28D1SqUkb2e3HI0Ncxm87MXXQC0h1o306I ZusQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=nY9OjUbo; 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-185667-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185667-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f31520c05csi10191755ad.569.2024.05.21.18.58.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 18:58:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-185667-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=nY9OjUbo; 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-185667-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185667-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id ABB51B23F6C for ; Wed, 22 May 2024 01:42:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 85DB642A94; Wed, 22 May 2024 01:40:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="nY9OjUbo" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 1FFEE339A8 for ; Wed, 22 May 2024 01:40:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716342029; cv=none; b=N3zyT5m8Z4vVMBBUJvlo+CxxElec9UBLNuyg0vlF6aLJu3RgHM38kycYSyiwqR4O62Cay1OpTD2CbGhQpcRSVbi9QRGsrk255XVRgKei/jyIbQLnFavgJPef9Pjb+07HvlKEQ1im9cC0ml9DwMcNv8zTaHlNQJcgrjW8we3zZwo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716342029; c=relaxed/simple; bh=FJaY5ZXsWt+iV/k6HY2WFFz74BTaJg/mMtL9qyrhSP8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=UxbrgjWIXe2lp9/1niz3662Bfc9VY7TXcY2cOgeZ8pX/H+Ep4jz+F5jDcncLqgiZUe4L5doSibPppzp7KEV+OEQCzrZ6Tpj5wA3dQ1s2BIRrJXO81g4dMFwi5Zd7gVCpZO964GXEXTwgzajKKD4RSK/aEk9gKCMTxbcqOSj9sTE= 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=nY9OjUbo; arc=none smtp.client-ip=209.85.128.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-yw1-f201.google.com with SMTP id 00721157ae682-627751b5411so138420997b3.2 for ; Tue, 21 May 2024 18:40:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716342027; x=1716946827; 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=N3tcdNqgpk0g0Qawt6D2SIU8FL4Y9j5vsBcc8xUlRY4=; b=nY9OjUbo8J/1K6KSfmzP93ciQH1ZkN1SQFK0scAlnFw3BPsCHA9otMjPsJ4OdAzMr4 o4IODDP3MUjcpCtOgl99cJtvgDmDGnUMrs4LfvZhpr33t7NPZCH8J/QaOJLSkENEQy6Y KsMTAISzXcD39VsGwgpk4yLv5X6ycrWn1VtXYWtMidCxgR+q0XP/9pQt51DP1L/dmUWs YeKSQyQpM4NpTDjI0htXkmnrYh+vEt36G0QErbBgSQeY6kH2pnxwbKbOpX7+uLiUPvO0 C0zBkhAfKorQ/7n7e18+FRyIGS5E/w/4Mn5BuWbTN91OjRaJhxM7LfxtD1ceCnoKOM/S /JDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716342027; x=1716946827; 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=N3tcdNqgpk0g0Qawt6D2SIU8FL4Y9j5vsBcc8xUlRY4=; b=k8YSl9SSMmrKTXWEAJVCr4iE1SgjfIDfctxSvMQmVzJCfOIAbwvDv1LhLCyxY1ZyJN 5T0FkgYgcnZrLdVmuUt9Px6n5saVRN887WAiWDSCVYaCWKKda18fD02JDYYgn/1iWwgS rh1E9pPuwrK6nko/1nCdSapa2oJl6zyj01RQg6EPYTIUjKNWnirnJHHoELeW0kdu29R+ PfV2+p/DWRgj/s0U5osgRnU5vBcftFoNyBMNtyPE0DS41apvFu+JHEfKKnAAJ+JRe/PV p4ROfLg0QW+265q8TNeNuJF8I80FdMRxQVNl3xaRG73H5F3vvXCI+LHZJb/9ifcgA4Iq SjJg== X-Forwarded-Encrypted: i=1; AJvYcCVOyr8yDpkFHSYTJHoP/b/qnLYgFYk7yRCmazCCYKDibSv0t9Uj7d9opSVe94Wz+cfSTPXo4iNdd7EmP0a/z5rIDnQqsd05QmhHZpQe X-Gm-Message-State: AOJu0Yxb0aBmQvWYJ4Slkh8v6DAQervIuxv9mNrUdfIa/lv0SOken7rA a4OIP1Ev9OUCm84jheMdlUDqqdUmQOeB3l8tmVs/BnCQYjpBQSQolhDMhI8fymSHAWHVqU1naJj Umw== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:4984:0:b0:61b:e6d8:1c01 with SMTP id 00721157ae682-627e487fd2emr1914977b3.10.1716342027243; Tue, 21 May 2024 18:40:27 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 21 May 2024 18:40:13 -0700 In-Reply-To: <20240522014013.1672962-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: <20240522014013.1672962-1-seanjc@google.com> X-Mailer: git-send-email 2.45.0.215.g3402c0e53f-goog Message-ID: <20240522014013.1672962-7-seanjc@google.com> Subject: [PATCH v2 6/6] KVM: x86: Drop now-superflous setting of l1tf_flush_l1d in vcpu_run() From: Sean Christopherson To: Marc Zyngier , Oliver Upton , Tianrui Zhao , Bibo Mao , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Sean Christopherson , Paolo Bonzini Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Now that KVM unconditionally sets l1tf_flush_l1d in kvm_arch_vcpu_load(), drop the redundant store from vcpu_run(). The flag is cleared only when VM-Enter is imminent, deep below vcpu_run(), i.e. barring a KVM bug, it's impossible for l1tf_flush_l1d to be cleared between loading the vCPU and calling vcpu_run(). Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/vmx.c | 7 ++++--- arch/x86/kvm/x86.c | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index da2f95385a12..552b6a9887a5 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6672,9 +6672,10 @@ static noinstr void vmx_l1d_flush(struct kvm_vcpu *vcpu) bool flush_l1d; /* - * Clear the per-vcpu flush bit, it gets set again - * either from vcpu_run() or from one of the unsafe - * VMEXIT handlers. + * Clear the per-vcpu flush bit, it gets set again if the vCPU + * is reloaded, i.e. if the vCPU is scheduled out or if KVM + * exits to userspace, or if KVM reaches one of the unsafe + * VMEXIT handlers, e.g. if KVM calls into the emulator. */ flush_l1d = vcpu->arch.l1tf_flush_l1d; vcpu->arch.l1tf_flush_l1d = false; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 60fea297f91f..86ae7392cc59 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -11264,7 +11264,6 @@ static int vcpu_run(struct kvm_vcpu *vcpu) int r; vcpu->run->exit_reason = KVM_EXIT_UNKNOWN; - vcpu->arch.l1tf_flush_l1d = true; for (;;) { /* -- 2.45.0.215.g3402c0e53f-goog