From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) (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 5148348F82A for ; Tue, 22 Sep 2026 18:40:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790102433; cv=none; b=RNnJ+ltX51oTvyWtwfw83ty95fxhkF62AJAsaCxCCbrYhFaTJYjh/WvrnjrPTuS1fVgoxs+Zst/6u0NtqvfVwYc+B2OcmoyspD+fyA1vmUCbH8m3aLoNRpVedAIISGp48hZx1tOyuVrYbl7TTZvknxzeek0Y6PwBTw0WlSK1KiQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790102433; c=relaxed/simple; bh=ERtLhWAKheJkkB1jYfwWgoVSdNN2wmMgOYzp/tzF/bI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=AGD4XdH92d+UvoayJuWqeb9FSzm26RMjmRocqYMSzYOJriigYkxxn5wQWDddI6r1ZlOe23WxVCe0+wlwKSJUFTMRwGb1WR6Rboapxyl93D34pH9qmvbNGJqfiKyDxInNNbOjy2FBaYD4k0h6U8jAX6LcvlVpeLptXxDrOz2G3tQ= 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.197 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-f197.google.com with SMTP id d2e1a72fcca58-855315ccb64so155715b3a.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=LEf8glrdbmTsqp1ZJXAuanyjfNHuIQCL0cosXh0hY6x5R0us1LI+Ve1gW/2jYAe7/c yuF/WbBr9OZFjInOlPE9TGAy4F/g8JAbt2wEMOXb1PTPkcTTq0X1IfZzc9d4wjBrv3PN 23zjY3wthVsdGfDEFngzHzlYGLUMs5e9rCMB52UKqDyV3/8JX1qJ3ZpN3St2rdDFv9GP EbwvpteuI47FbaV05aWussutVnJF3AlVtquJHXWLROENm7MiJ/TZcneLhLQzW0MZEttD JIZX9MLlCL1d31Th2NXxYIPfmT3bslSOSI0MO9VRkvYKabRNzwkJi284yW0xl67Lv+js kqmg== X-Forwarded-Encrypted: i=1; AKwUvBxjWkEZhDkYSfBgfQCzHWC1EpfRMGE+I80XFW/7YFPFTkJC96DYOlifwmYvrI1+yTApz9c=@vger.kernel.org X-Gm-Message-State: AFuF++kcT6AsmKdobpsO+QPl8Twso5gqNxhzOm8aVZEspxJF9IRrZ7+c cjD+IDqRIjoWpOQvmAEjL09nkR+i3vuz+Xt4KM4eGJZs9ZEiYytVD3vLVdsEIfwnXBRkzbqOafx 9Vn/ypA== 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: kvm@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?