From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) (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 7CEB748F02F for ; Tue, 22 Sep 2026 18:40:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790102432; cv=none; b=R1v5PCZWKDRTvCbStZ3QRgyydcAGeFcYV+EeMyoWfdsSuyn5C5nBUmhSIo3YdlmN4sUG3mNRr1LeL/653rDZuX9SsebBwnFFdUEV2rIWNXdig595tobEXRrXbR97Zv+vyqDiecGiM0imy6chCP8L8KAfftaloeJWQ4F59RejCEI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790102432; c=relaxed/simple; bh=ERtLhWAKheJkkB1jYfwWgoVSdNN2wmMgOYzp/tzF/bI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tOz3Hsy21gmCD3utOLzTTqR4nrpXm3Kugb59nyHK6ay/+zpbIBSD9owlF7NeuDeu/z79orNp6RZw/uhz5A1z2SragxMJe8+wM5nY6c2TMxYDvYuFziWBMkLLhIsS6uVtxoZHNT1LqJc5Oa52fv2rvadbyopJiCsx81iix3K3+mI= 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=gDh54AWb; arc=none smtp.client-ip=209.85.210.199 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="gDh54AWb" Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-855315ccb64so155711b3a.3 for ; Tue, 22 Sep 2026 11:40:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1790102431; x=1790707231; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=22qb4IkKc4A4y/WM6dRh1XUq626SL2Lh5OkUO2ttVr4=; b=gDh54AWb42iXpIZrXmIZf09Q6OXRF0pMdfM4PXnUZ1AMAqtpsp2xwvbdZqMzmJ9zhv fnOg5s2Ux7EC1z7EaCjgNFT0Evx+LV7/OVVdu/Rko1iRyrKudmddahovHgbDtDHef0Td hjpKyHDVd2u+B3vxVExVNGJlvz5t3rfiC2ByeqdU9X8XpeUosZ9yCxD3vCK9fkYv/Yu7 v0q5cPWhSXeC5NU6TYOoVMLm6hxhHJe7bulqkdqJz2muo1W/nDD1hd1ZQsNpsoYyYy1Q yJiRR1LlyUVrgqv7jzbSfuHQuGFG4bega/8tufhywMjG6sx84gfGV0KnK+BkNmJG763R BcWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790102431; x=1790707231; h=content-type: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:content-type; bh=22qb4IkKc4A4y/WM6dRh1XUq626SL2Lh5OkUO2ttVr4=; b=cs6gw8qfR0kfTPls/SR3DoKBrPVKSAAl9FKuiwwFMw7o5Xbppj2zwDBUKs1UcQkqNl 96zEWntwxfFVvtEC/j0GmzMl4E2vRT8yxN8GgKVjBmX4tui3CjEjMAHeaaTePJwx1Dz+ 4V6YPceYXzrtttetWjT0S6pfLLxKZN6MhqsUUa8x4ejt/TYMTmTfVC7Vt6ift41Bz68W wgO6PY6TsJ+6n+dkHFaUuCqRER9u68MgupbdVQQwIkHIAGOlRdtIsHGTpQPH2V/IyLQu 2NA4Ta5REn/jf+RGWEG3m5qe4ALEkAA/yXv2lFSeffPrMrk0/na7dmFugStwdSfnhhyQ minw== X-Forwarded-Encrypted: i=1; AKwUvByxkoIXvJF6dvazPWN38T/W9+bWxazXpjRnPb568J5o84zy+BJLQ8/0Kq0xd9PHC6zJqP76vfhvCpVm5Lw=@vger.kernel.org X-Gm-Message-State: AFuF++ksESrWCZl70Y6uyeBeeLnJY6DVrYl7WcRANd9hwStKJ4EWtsIH T6kCfE8cihxe2QvL5+xHGhZT+H/ZiLXTn28ZHHzGX+Yg2P8dU8gQFrbDlbn/PxwySTBLK/akUT/ hhF6gYw== X-Received: from pfbgd10.prod.google.com ([2002:a05:6a00:830a:b0:863:cabd:d30d]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:4396:b0:878:3507:8d5e with SMTP id d2e1a72fcca58-87d1bfae6abmr510835b3a.37.1790102430559; Tue, 22 Sep 2026 11:40:30 -0700 (PDT) Date: Tue, 22 Sep 2026 11:40:29 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260922-kvm-arm-prefault-v3-0-787bd3bc7e3f@kernel.org> <20260922-kvm-arm-prefault-v3-1-787bd3bc7e3f@kernel.org> Message-ID: Subject: Re: [PATCH v3 01/14] KVM: Allow architectures to disallow pre-fault From: Sean Christopherson To: "Lorenzo Stoakes (ARM)" Cc: Oliver Upton , Catalin Marinas , Will Deacon , Marc Zyngier , Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , Paolo Bonzini , Jonathan Corbet , Mark Rutland , Fuad Tabba , Randy Dunlap , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Jack Thomson , Jack Thomson , Alexandru Elisei , Vincent Donnefort , "Aneesh Kumar K.V" , Claudio Imbrenda , Leo Soares Passos , Wei-Lin Chang Content-Type: text/plain; charset="us-ascii" On Tue, Sep 22, 2026, Lorenzo Stoakes (ARM) wrote: > On Tue, Sep 22, 2026 at 10:36:49AM -0700, Sean Christopherson wrote: > > On Tue, Sep 22, 2026, Lorenzo Stoakes (ARM) wrote: > > > On Tue, Sep 22, 2026 at 10:23:43AM -0700, Sean Christopherson wrote: > > > > Rather than have kvm_arch_vcpu_allow_pre_fault_memory(), what if we add a more > > > > generic kvm_is_vcpu_loadable()? That way we don't need to worry as much about > > > > the return value, the connection to vcpu_load() is obvious, and we don't need to > > > > add another pre-check if future (or cleaned-up existing?) ioctls want to do > > > > vcpu_load() in common code. > > > > > > ...this is exactly what I started out with. > > > > > > But then you are in a pickle, because _really_ you need to do that check in > > > vcpu_load(). Which is a void function. Which is called by every single > > > architecture all over the place. > > > > > > So you'd have actually no way of signalling the error back. > > > > > > Of course those places are arch code and you could say 'arches should know > > > better and if they call it it's fine not to call the arch 'can you load' > > > function. > > > > Yes, that's my vote. It'd be easy enough to clarify that "rule" with a comment > > in linux/kvm_host.h. > > I note you dodge the actually difficult question of what this wrapper function > would look like ;) Oh, I was thinking we wouldn't bother with a wrapper. Because I agree that providing a complement to vcpu_load() would get all kinds of messy. Though we could harden vcpu_load() with a WARN_ON_ONCE(), which in practice would prevent the vast majority of violations from making it to a final kernel release. > > > Instead you can make the predicate 'don't prefault on a not-yet-initialised > > > vCPU' which is pretty sensible I think, have a specific place to put it and > > > all's well with the world. > > > > But look at it from an x86 perspective. Pretty much everyone will look at this > > and expect: > > > > bool kvm_arch_vcpu_allow_pre_fault_memory(struct kvm_vcpu *vcpu) > > { > > return vcpu->kvm->arch.pre_fault_allowed; > > } > > I'm not sure I really get your point here at all? :) > > Why would it matter what people who are too lazy to go check the implementation > assume about an arch hook? Because I don't hate the people that contribute to KVM, and want to make it as easy as possible for them to not make mistakes?