From mboxrd@z Thu Jan 1 00:00:00 1970 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 19E3F35B14C for ; Wed, 22 Oct 2025 19:08:47 +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=1761160129; cv=none; b=WAXffFl88ArostEUbttBgj/mhq5uRf8oYhXpujA+SArVlsSkRWvTORzOQvth0kiGFcDbhLcldtupkuG0DnKw0qe71KrpsOxwKbFYfvI6Sya+erkpw8EX+l7OjlGQGBvTCbqUCgA5cLcNe8jm8wkaNG8Uzc1xZYTE8z68ONkN8qs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761160129; c=relaxed/simple; bh=k7EXMNgqSkOA+7R9iYr3lcFkZvZ8bFqZ1wal4qwtUZY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=GKOdEjr9TEHSYWaDKqkygtOfVayHOkv2+kLeeFrgOtgK1KcB/7iEx0tcefMaVwndKWRPJICXnVBgdFOBnMXx0D7ahhpxdUbXiLrEAE0CxyWlWSf8J3W/KLm9u0D/Vqch7ogsHvCe5Jc4f2mv/1PtpsLgkPTZPDyMs0mNyxR5AV0= 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=udGeY5Ml; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="udGeY5Ml" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-781253de15aso15805849b3a.2 for ; Wed, 22 Oct 2025 12:08:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1761160127; x=1761764927; 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=wREzy7rE27X1qKmfXOWprRl7YFBX8aFkFx3LWlFCsNc=; b=udGeY5MltLB2RH7DvlzkYeooe4oQPtGy2PCB0U0b3erTRmgM+erdHz2iZCMZTsaaDV EXdNtXOC4rPXSS3OTmJgs+qkDUW+GS8NxMGCzHZE6cj7vveLI36tMLTkQU5tNnUTYmMG aal731M7rhqSCucFaC5bC3WRwV819eTUPSr16aEGUDMz2H7O7DwDTG4A1ySfaujrb2jg ktF/pwOk+mIPCm5GEkeAmcyAMM/JgbPoJ6Wtmz8ZVQKcldgcM/5cL2th1MkCJkQ4YPRm 3EfDSq6C8M8IrcwuoWS8EQQNkeANRCVtyb8A06pxM0Lp/38WsH/22Hl4MIVcLxGQRgkb cxOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761160127; x=1761764927; 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=wREzy7rE27X1qKmfXOWprRl7YFBX8aFkFx3LWlFCsNc=; b=RdbP9MuYk0XxV6nM4oQDblrS8vSDayjUum9I1LwRyCQ5hiAg1R7tlFh69ekGIhgCH/ pjaudkXRtwPDwKvo6dovcjB4jOo8nfZ/RmGrjaILar8eTlVU5GXuVh92oAAyok+TchAa WTC7VwDSb8X9hJM5VHJsKa2vkoSvieAlUOj+riAb2iLG6kue+VpSVB8yTF3F8/ghJjP0 hTs6jTpRPClFUeySLgejNiIou8rFx43RPKzU1xzO1cIIPQZNDN/jFNgwWBAnp/Pa1Ogw yNGO1V/kT8gxVGlGaZOnCHKxM8CX//V9waxynrYsL2dKlAmKBPgfuKaSJTTreXJX6agy XLEw== X-Forwarded-Encrypted: i=1; AJvYcCWcT5BinhM8gXq0To6lEoFUiqQlXdVZaV3q41bzLopSNnhlgJCRHFBkjTyNJ4R3nPwylSyND2M/2NGz@vger.kernel.org X-Gm-Message-State: AOJu0YwGWwLB6UxG1WZTsPT5SNB0iX8BXCtjEp6Ua1/ACl4zyVR6XF8L lqdSiiywvPtBp99NrNfVcKLIl2AcmBaI3eUWSdZa1Hv/sG9e0Y5iWtX6IPaPLIO5z0ce+M4QNQc cxfkWwA== X-Google-Smtp-Source: AGHT+IG7bMbvOV7PjecaO9CgeAeXZcwC+wb3hcO8vOg4iH6Jor9tS/5vQmEcVRzTkSnVuCY2g2HzBv4NWV8= X-Received: from pjbpc16.prod.google.com ([2002:a17:90b:3b90:b0:330:9870:9f18]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6300:218a:b0:2e5:c9ee:96fa with SMTP id adf61e73a8af0-334a861743bmr28027967637.34.1761160127099; Wed, 22 Oct 2025 12:08:47 -0700 (PDT) Date: Wed, 22 Oct 2025 12:08:45 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251017003244.186495-1-seanjc@google.com> <20251017003244.186495-11-seanjc@google.com> Message-ID: Subject: Re: [PATCH v3 10/25] KVM: x86/mmu: Drop the return code from kvm_x86_ops.remove_external_spte() From: Sean Christopherson To: Yan Zhao Cc: Marc Zyngier , Oliver Upton , Tianrui Zhao , Bibo Mao , Huacai Chen , Madhavan Srinivasan , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Paolo Bonzini , "Kirill A. Shutemov" , 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, x86@kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, Ira Weiny , Kai Huang , Michael Roth , Vishal Annapurve , Rick Edgecombe , Ackerley Tng , Binbin Wu Content-Type: text/plain; charset="us-ascii" On Wed, Oct 22, 2025, Yan Zhao wrote: > On Thu, Oct 16, 2025 at 05:32:28PM -0700, Sean Christopherson wrote: > > Opportunistically pass the spte instead of the pfn, as the API is clearly > > about removing an spte. > >From my perspective, "remove_external_spte" means removing an external SPTE (not > a mirror SPTE). So passing in pfn_for_gfn seems reasonable as well. > > Additionally, passing in the pfn eliminates potential concerns about incorrect > spte content. No, it just makes bugs harder to debug. E.g. it doesn't magically guarantee the @pfn matches the pfn that was mapped into the S-EPT. > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > > index 48598d017d6f..7e92aebd07e8 100644 > > --- a/arch/x86/include/asm/kvm_host.h > > +++ b/arch/x86/include/asm/kvm_host.h > > @@ -1855,8 +1855,8 @@ struct kvm_x86_ops { > > void *external_spt); > > > > /* Update external page table from spte getting removed, and flush TLB. */ > > - int (*remove_external_spte)(struct kvm *kvm, gfn_t gfn, enum pg_level level, > > - kvm_pfn_t pfn_for_gfn); > > + void (*remove_external_spte)(struct kvm *kvm, gfn_t gfn, enum pg_level level, > > + u64 spte); Thinking more about what "spte" actually tracks, I think I'll rename it to "mirror_spte". > Also update set_external_spte? Ooh, yeah, good call. And we can use the mirror_spte information to assert that KVM expects full RWX permissions, e.g. that we aren't creation a security hole by letting the guest write memory that KVM thinks is read-only (extreme paranoia, more for documentation purposes).