From patchwork Thu Jan 9 20:49:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 13933222 Received: from mail-ua1-f73.google.com (mail-ua1-f73.google.com [209.85.222.73]) (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 7CD002054E9 for ; Thu, 9 Jan 2025 20:49:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736455802; cv=none; b=N2UY92YjBcE+wDXcxGYzA0V7m4/MSPpC439OZ38LJ+3xsHobhlMPU9UhYtZHi5UO4rf7gg7Cxfd0V06G60def4IS9OoD/+gXyZKleKh5f+U/iEPp1fEacLstfZ0KtO9cfq11c4zGAj4c94FL+vYF0WpqPQXa5aV9VgC7KdUE6hY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736455802; c=relaxed/simple; bh=tSVByeVc+YvO1YwpxO6WQbJnBeXOFHCPwH2YC78/pxw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=BSpCw4PQDj70yQi4EKUv1KV+SMHIgsrS6+ppqvMSJhgvgMOATGV0oVVCL1Yer3Ee42B3UvMg6CboxY7HnAdkTbAkJHKxTX/K+qi+Wna+jvU4xJ0bncTmJm7XjQZeJUYEHk7CVjSSGEEpNODU0+KP+/nTbn4HnZBK4DZqDhCEG6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jthoughton.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=mcF52Ldy; arc=none smtp.client-ip=209.85.222.73 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--jthoughton.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="mcF52Ldy" Received: by mail-ua1-f73.google.com with SMTP id a1e0cc1a2514c-85ba1d9dcf8so359753241.3 for ; Thu, 09 Jan 2025 12:49:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736455798; x=1737060598; 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=1DrcQjgptnhIcToWnmFksBp0MRaAX2CW6X5qNo+eD6A=; b=mcF52LdyaRfn8cLItO/k6gTIxPtxYCogEWTleb8jRHW5KCCfdg6b4Wxm6SdmctkCMX 666H6Ru4TkG1aTe9t4Cx2NzHHduVFIL1s7ZFcPOhgwUIzhQVeJHbyt0aeS4j/Oapc5fu 7WQ3Fgq27FPX/bljvQi0dHJd4D7DxZu8V4Adm4i7utDYAPDeC3sqkPvp9A+lDvOTQ/zV ffGQKir7iTjt/Et9/bvsItbKw6jxc+VOWSL9KKCaMOfpIEm9vfkeeUofLque5fwYuXoM U1gMtxRzhZkup6Zk6CeoK3meC4LYDukumG0Ay0mTX2jVcv+XULeQyFs+sfljBZPOEE/U C3hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736455798; x=1737060598; 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=1DrcQjgptnhIcToWnmFksBp0MRaAX2CW6X5qNo+eD6A=; b=Yij/1L1fGxxinO410GKapI/ZcLlBSZ6aKVTKu1HNZe0HgZ5UkWPOe3RppEXqr6nx3M wtjdn4wY2TZsLSpowUsPH+HRFVygVawmN2WhJ6ZPi1FQIfrlB3f/xDnUpLXtHfX4ImJw J/QIQbVo0cu9+4zCa8wCfnKpzdGIdBh0yttxyQhCLbAfqisDqEaNzLYIzzoFhMCBNN/c VjP9SX6qNXsKs/K25V0eLqSyPz4CdjLJXtJFxntds6EKX3JkHMk9WndciB7gDe3adw7r JeNpBNBf73gUA+Gzz1uQqW+lUbE+PAeYd7ysHbyZoRGnzChUBkimhf2aRKbTny297OCR 9CpA== X-Forwarded-Encrypted: i=1; AJvYcCXr9bqu/o0dAyeG5Wa8FVaC7YCqbi+ezWAGzewi7Y3c/5G3TwZN00zU6j+StgqYiHcw1tQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxVqm0J7+lnkHMeH/BwO79vymqhjdmbhHRjG2+HjhHhUCZVRvQ5 DPXtXlNLGZze4jhK01vTB0pvgP0o7L0os/18Y/SYAlV+GxlGMlmSASpKCd9bo+I3bjrZ5Nk/bGq /RsMHZDJDcvnNCnLE2Q== X-Google-Smtp-Source: AGHT+IEK0449o9KbC3fWak3S16jydYyIqzxOV/2eZ44AIR7w7I0DQuvF+HeqMnZYowZ6lm/VqNUOgc0IX+KhZU1E X-Received: from vscv18.prod.google.com ([2002:a05:6102:3312:b0:4af:df7b:f439]) (user=jthoughton job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6102:2c02:b0:4af:d487:45f3 with SMTP id ada2fe7eead31-4b3d0ffc73fmr8314563137.23.1736455798514; Thu, 09 Jan 2025 12:49:58 -0800 (PST) Date: Thu, 9 Jan 2025 20:49:20 +0000 In-Reply-To: <20250109204929.1106563-1-jthoughton@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250109204929.1106563-1-jthoughton@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20250109204929.1106563-5-jthoughton@google.com> Subject: [PATCH v2 04/13] KVM: Advertise KVM_CAP_USERFAULT in KVM_CHECK_EXTENSION From: James Houghton To: Paolo Bonzini , Sean Christopherson Cc: Jonathan Corbet , Marc Zyngier , Oliver Upton , Yan Zhao , James Houghton , Nikita Kalyazin , Anish Moorthy , Peter Gonda , Peter Xu , David Matlack , wei.w.wang@intel.com, kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Advertise support for KVM_CAP_USERFAULT when kvm_has_userfault() returns true. Currently this is merely IS_ENABLED(CONFIG_HAVE_KVM_USERFAULT), so it is somewhat redundant. Signed-off-by: James Houghton --- include/uapi/linux/kvm.h | 1 + virt/kvm/kvm_main.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index c302edf1c984..defcad38d423 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -936,6 +936,7 @@ struct kvm_enable_cap { #define KVM_CAP_PRE_FAULT_MEMORY 236 #define KVM_CAP_X86_APIC_BUS_CYCLES_NS 237 #define KVM_CAP_X86_GUEST_MODE 238 +#define KVM_CAP_USERFAULT 239 struct kvm_irq_routing_irqchip { __u32 irqchip; diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 882c1f7b4aa8..30f09141df64 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -4811,6 +4811,10 @@ static int kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg) #ifdef CONFIG_KVM_PRIVATE_MEM case KVM_CAP_GUEST_MEMFD: return !kvm || kvm_arch_has_private_mem(kvm); +#endif +#ifdef CONFIG_HAVE_KVM_USERFAULT + case KVM_CAP_USERFAULT: + return kvm_has_userfault(kvm); #endif default: break;