From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86CBF1AA791 for ; Sun, 12 Jan 2025 09:55:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736675743; cv=none; b=UHW5fpG/zL9iD0EEuRq2l0B4fyxKZc5yoOD7eYbi/acOWDqDikPmJAqaZ/yhrsnKG+JiyscU4FS4H/85OuE6fbNUfvxUq0vuPLqA7qaeCOcdQIRsLQvhi57MxSB3Jz2LXnIFeIjf1ob9iUffMySnEdjaUQnjJqyKODj3RfbX6Go= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736675743; c=relaxed/simple; bh=RUtYNoQ9BCw8rR1uJmMHYjgVRzEI8pcTkgifDneD3LU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sCuUt33pqgPhFIaOY/Zudet2H4xioWA2BD1OvnnQiJsZMqYmI8iAN5Cjk1A4jVjnUZemQLDqa5r78lyQ8lg4mY2nFMhAutYtWUbyqWKc9hYPwzsEbRW1maN6Zg8ceockenrTm0SxcXCsdvTNyBLU6ZQY/fA61vDGMJBEu4zwYZo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=M0E9jxzt; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="M0E9jxzt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736675740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ia6sv5K1rPK0oxjj8pHkn374uhH5Bs7h1d/ShzUvYRM=; b=M0E9jxztDdJkw2bbe0rYrqZDvrH1u2ZM7c1R4oURENTFJoeS48DBDLt5cOMWuqf6zwC82o KcPoEcGRNb0YuUZSA5ny+WjB1ZgIhb7HQwK8k1VtZfXw0tvHYXXLZaEZfPfyRH7tswFRPw VCoMq/C3RyC6Kv+YdZ/BRqWLLGlBWVk= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-116-MSiWOux3MBuBZxTJ1vXCSw-1; Sun, 12 Jan 2025 04:55:39 -0500 X-MC-Unique: MSiWOux3MBuBZxTJ1vXCSw-1 X-Mimecast-MFC-AGG-ID: MSiWOux3MBuBZxTJ1vXCSw Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-aa6732a1af5so359839666b.3 for ; Sun, 12 Jan 2025 01:55:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736675737; x=1737280537; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ia6sv5K1rPK0oxjj8pHkn374uhH5Bs7h1d/ShzUvYRM=; b=xTs/beEt2z5u1qWbzg1efKqFEMK7uyvN0+ZELGnm2MlC+eWZUsFN2ngdCVDXX0C+5d voVCEo6eVKHUeLoZCTDuoYTacF3jD0XQFpvBPmRBRI8IUoM75txEcp39vSNpuawFPVxb 206S5e8SfrE0Ojz9JdRWw3kuK3oL2x1xvKc5BSP74UfoWi1/ptNUChEh+f3aRo5kBcM5 p+52v3eKIF0UPHo0fNsJG1bjKChtOfhUBKIPbbBzWPh8rQanYxZYwSg32dK63mM90FdC KSBBGV7fp9g16KWUIUSy7BiMR+m76aUXDqhFiMEBJAXXbrkgOjVBPpw1g7o2p55eh+9A m7Rw== X-Gm-Message-State: AOJu0Yw5HIAijaAVoOw7x8eMK5K8QNS8dQGX9y4KcDSPmKOD3Y8lnGvH s/nVFYgF1zFGcLujeGpCLt++0QGIy1a0enA5AnGVY1BwTRTbRxS5jYfWBBS7pJa5cj08Q8HJ09o G9WlGBwRm2/pyv93SZF76s3h8tIv1vUEjDv/Fp8OUJJxOirVGQ1Ou9dgCQe5sl4WqNpEfGUE8Nm B5XcLsIZsp9HoOTAN/u0vZ5FunliA7cQN7FFHXBY2skkeaLu77 X-Gm-Gg: ASbGnctF12idqfkD6V961w3FrfRi6/Ah9pGQ5KgM7iizb/oFFnaVxzcYh7kGKPjYH1r aXFsCYpsCGX5BPeYu5ZkITHbQVu9fMU+LVPAYK1mvLSthJfaqkNgRYvOAedSEMvgxITIp59djJA h2aw/VIHauaMoF619E1196Psno0+9Hoj4rhHYtGVR3VorNp+uAgWCBCg/zZprJUz4CO5nkMHD5s ZBdHsFq+eV8P4v50DelPfPo++gV9dK4Nd/3akeUQYdMR//bebFgMtu0Kpg= X-Received: by 2002:a17:906:478f:b0:aab:dc3e:1c84 with SMTP id a640c23a62f3a-ab2ab703f93mr1611128966b.17.1736675736696; Sun, 12 Jan 2025 01:55:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IE57lWwmpDxmyLrpFomxsQp5nUpO/tCN5jrf13BA6wccxa5tYF5ClNyyJ2YVR15koS+dU7MVg== X-Received: by 2002:a17:906:478f:b0:aab:dc3e:1c84 with SMTP id a640c23a62f3a-ab2ab703f93mr1611127466b.17.1736675736279; Sun, 12 Jan 2025 01:55:36 -0800 (PST) Received: from [192.168.10.3] ([151.62.105.73]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab2c905e283sm356143866b.31.2025.01.12.01.55.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2025 01:55:34 -0800 (PST) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, linuxppc-dev@lists.ozlabs.org, regressions@lists.linux.dev, Christian Zigotzky Subject: [PATCH 2/5] KVM: e500: use shadow TLB entry as witness for writability Date: Sun, 12 Jan 2025 10:55:24 +0100 Message-ID: <20250112095527.434998-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250112095527.434998-1-pbonzini@redhat.com> References: <20250112095527.434998-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 6824e8139801..c266c02f120f 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) @@ -489,9 +487,10 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, } local_irq_restore(flags); - 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