From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 68E1419E7F7 for ; Thu, 9 Jan 2025 19:01:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736449268; cv=none; b=Zossdc9mOhxU7IqSST5xWlLla/xNP/V6lTzxnYlrz2RncEebGuRxkv0xxEzIo74HnnffbV7ZgGGNfSUkwZDIqDzdCAibwKpEDTnXynRSTNccZafg8d4/7kRlu0P1erdryZbM9qiBhSiMbProoXfEKeuNG9+2mapyGwyl69Wy3XM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736449268; c=relaxed/simple; bh=0Wqndvrw6Ac797CYqWAX1cSbrSIBep0LKHDXmfAwv3g=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ucbkDiPGFLDVBgeJJ3wZGe67mb9tgTSo2DPO+25hGbkALrFRd3dSZRO2p0R2jKWqaA9jLJq3aRDza5SbHCGTtBRssetHshB3V3iGrHhJPv3GiL8cd9A8JqMmrFSJrYVnR0Jtfhr5nrJAnE46bnV63fTxqyyVoLHdQQ5TEE09Hww= 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=WlXOPkDx; arc=none smtp.client-ip=209.85.216.74 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="WlXOPkDx" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ef6ef9ba3fso2269142a91.2 for ; Thu, 09 Jan 2025 11:01:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736449267; x=1737054067; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=+HfpA5fbP7TfH76TZ3Uj5yQZsZSY/yn7fUa0meeoBcw=; b=WlXOPkDx2nNDuocuAGhSHirLQrhW/iMA0Q2KlM3HwPVgDWLP/m8ZYV668qKktvWCow xGgles4RpIrEj1rCieIV/AM76MKJN3wot7N+d6MQZ9YrVYlUUtDUuocOnrAadwpECU+R jjOuNKO0UVvbJ5LQDz39kPOKSYSXMCxn3E0d/K6SRUNSHZ4YaoB5XrAqmzu4K7fopLNe /NzG5QXv+MH01jkFavsNQW2eTY+EVTPOgErgD8g9O3QFa9fvk/rI0F5DHnIV5F4gQX2N BxJF63yvxpClJspuIQvXNYRrpYQnFr1XfnTCWuJoTxaZthxMB0gyHuWsCrh/6g32ALne 4Oag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736449267; x=1737054067; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+HfpA5fbP7TfH76TZ3Uj5yQZsZSY/yn7fUa0meeoBcw=; b=qXoHbp3uOfrFLkNxXznCyw7jdmywxhTYsISWm76LnAp0nSsOK2tjTgQ3gllvlnsZTV nTDbThenflM4/o3SqX5GgHkyRZWr/CqPfzv9fXWSG90taUhEOnyamuo4iqmO3Hk2qfS8 JlPqe1U1PSUHXzF/KN3ZEwLrrVZeudPshah+d/ToQjEgwzxkrbslO5X3Nh2KiGH6gRv3 jtr7M9xgSEZUG3dVoFCYoVt2Lv2bngRR2VxT0ymUzPWAxWYIJs7/+eTsg69wpu/aHeQ8 z5tWz28uBxyvwCqPgH/vEVum55tL16j/udijO3Yv9yQy8n8m0dASFR1k6Ybnt8g1S3zE mq1w== X-Gm-Message-State: AOJu0YwiXN+I/tSESPP6BauPGH+ZDzLA513w5JAgkvxVhz8HuDdHsZZ6 vGhPiaw4bi9A0FSlMOtap8K9j/7623uWCPaRd0HXGwd6EBUmbBFULmiQl618P9U0oGplbF6s3cD nfg== X-Google-Smtp-Source: AGHT+IEy+gndLs4E1tSPKEcp4HwCWd68h7GZr39HDdXY/jAdD+K43aJiHJRninKh3yqF1SWahOdjjhE3bz0= X-Received: from pjbqb12.prod.google.com ([2002:a17:90b:280c:b0:2ef:9239:aab1]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:fc48:b0:2ef:e0bb:1ef2 with SMTP id 98e67ed59e1d1-2f548ecc3a7mr10739900a91.19.1736449266829; Thu, 09 Jan 2025 11:01:06 -0800 (PST) Date: Thu, 9 Jan 2025 11:01:05 -0800 In-Reply-To: <20250109133817.314401-3-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250109133817.314401-1-pbonzini@redhat.com> <20250109133817.314401-3-pbonzini@redhat.com> Message-ID: Subject: Re: [PATCH 2/5] KVM: e500: use shadow TLB entry as witness for writability From: Sean Christopherson To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, oliver.upton@linux.dev, Will Deacon , Anup Patel , Andrew Jones , linuxppc-dev@lists.ozlabs.org, regressions@lists.linux.dev Content-Type: text/plain; charset="us-ascii" On Thu, Jan 09, 2025, Paolo Bonzini wrote: > kvmppc_e500_ref_setup is returning whether the guest TLB entry is writable, > which is than passed to kvm_release_faultin_page. This makes little sense s/than/then > for two reasons: first, because the function sets up the private data for > the page and the return value feels like it has been bolted on the side; > second, because what really matters is whether the _shadow_ TLB entry is > writable. If it is not writable, the page can be released as non-dirty. > Shift from using tlbe_is_writable(gtlbe) to doing the same check on > the shadow TLB entry. > > Signed-off-by: Paolo Bonzini > --- > arch/powerpc/kvm/e500_mmu_host.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c > index 732335444d68..06e23c625be0 100644 > --- a/arch/powerpc/kvm/e500_mmu_host.c > +++ b/arch/powerpc/kvm/e500_mmu_host.c > @@ -242,7 +242,7 @@ static inline int tlbe_is_writable(struct kvm_book3e_206_tlb_entry *tlbe) > return tlbe->mas7_3 & (MAS3_SW|MAS3_UW); > } > > -static inline bool kvmppc_e500_ref_setup(struct tlbe_ref *ref, > +static inline void kvmppc_e500_ref_setup(struct tlbe_ref *ref, > struct kvm_book3e_206_tlb_entry *gtlbe, > kvm_pfn_t pfn, unsigned int wimg) > { > @@ -251,8 +251,6 @@ static inline bool kvmppc_e500_ref_setup(struct tlbe_ref *ref, > > /* Use guest supplied MAS2_G and MAS2_E */ > ref->flags |= (gtlbe->mas2 & MAS2_ATTRIB_MASK) | wimg; > - > - return tlbe_is_writable(gtlbe); > } > > static inline void kvmppc_e500_ref_release(struct tlbe_ref *ref) > @@ -493,10 +491,11 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, > goto out; > } > } > - writable = kvmppc_e500_ref_setup(ref, gtlbe, pfn, wimg); > > + kvmppc_e500_ref_setup(ref, gtlbe, pfn, wimg); > kvmppc_e500_setup_stlbe(&vcpu_e500->vcpu, gtlbe, tsize, > ref, gvaddr, stlbe); > + writable = tlbe_is_writable(stlbe); > > /* Clear i-cache for new pages */ > kvmppc_mmu_flush_icache(pfn); > -- > 2.47.1 >