From nobody Fri Dec 19 15:46:15 2025 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 5F3B2225403 for ; Thu, 20 Mar 2025 14:20:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742480431; cv=none; b=J6Wm9ikAWwOOp6RrL1gpRJ+bucY5vARkjs/Yc329KYIaY4bpFLAqJGVPrVHBtzkFfmVtmSeKwzQk49aTB00uyDikOCf/BHMlIASrm4ZBHOWInjH7Sh0jsbb6LPKYDadMiF+j08KAMNVmcR7eGIDfxv2pOjHtf2d4gJ9nd/ylulo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742480431; c=relaxed/simple; bh=Il0oi8W0P1a3TdzcT4YRMppA6PiszW9iVacc6BETtEU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=EiXBfeUxjf56+SuauGGr6g1GKEoFLaP3vbNXYzKlrmO2H1l8hcfhH06gtfU1nAXAJ4V3kcvjy4213KKTsjAJNpOPo50S0lO0F2X9ml4oFyt8Sqsv26KVFo8hRIUY//rgN+18q/M3+R6/LphL3C08tlyA5LGuisPWuxB4gyvBGZo= 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=3AG9xUgc; arc=none smtp.client-ip=209.85.216.74 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="3AG9xUgc" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ff7cf599beso2037420a91.0 for ; Thu, 20 Mar 2025 07:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742480429; x=1743085229; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=qmMYNbiE7NCmjn3AfFSyN2d7EeiAyZE9x1WOdP/HlBU=; b=3AG9xUgc3lGd6Pprwr5yr5yEN1mF7TejSfjEUZ/gzhImLPe8OsrvWOCIAtz4MDuiJn CwyQTTwYdjpSjPRJPcpsIt2EnuaU/4l4959u0cEwtvQaewkwDAmej+tCF55jGUiJ+vjL ldgcB+C4f1ddKuFBxU0tIZjIHBZ+c86EKWQjss74HgXc1lbOJc2EQFDL6Nv6YTyhLxsa cJG8PUfyhhvQ7h2FXFS1KVCl0NVZ+EQFeadT25obuVL9vLe8+LrfUkYMN5a+fKRMNzQR /EAqe5WJY+VCqok6IhnApi+JY/KQN6K9LIO5jsp6uv0xPMGDczTOjlGJ7MdMGYroquI3 zbeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742480429; x=1743085229; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qmMYNbiE7NCmjn3AfFSyN2d7EeiAyZE9x1WOdP/HlBU=; b=I53q5yq5Hm3QmxM8w2BYt+alBovWHpBUCYx1YC8Qw6mUOwACseBSjinXx4JGa990ZW Q4sihwHpW5cV7qnE1qeMTX1azcI6miGQfsPENKl1tkQprMNoWo0K1CkgFimFwhwA+DtJ 21jFhgzsxzC10TPCo5cUOZdOLF2JbzFiXaVM7drk3R3k2fjr1QOOthZQsFqfZBlbF5pf vBBxa2LN1PZu9HQDtIRA4Wpmjghuri+TU4vkaXWtGvx24FmqWYYBNgzGaay7rS1Zx4yV NuLouHIa+bq0ncDQUvW1uw2DEP5pIKbihO8eu0SOSzCZZfwvHQSqjxSsDG4JpItYFqLW tRww== X-Forwarded-Encrypted: i=1; AJvYcCWfrZZAMjWFji8wwRW5EAURq9/WUXEs2JnEMAELcTXcCyzkUy9keJnoGqU/yudL46K/7R50ycdErTD6lCI=@vger.kernel.org X-Gm-Message-State: AOJu0YzmdJKR4ApPlnvoFIdZg00I086KpmubBzTNvy5n7jKYFfrNqIzK 0w4SMbZRkhNTE2uT083lSIsvZc2AyyQEjigWZecCK9WNStDYKu0BHXZGRJzXX45hkvy0CR+ahle RKA== X-Google-Smtp-Source: AGHT+IE+kfb1HoHRnQ267XvStqDZApTqRyoY0YWXiW9OB48WA4CtrHH/pA04OI5VxdB4Gu95vkhQH/SyzBw= X-Received: from pjur8.prod.google.com ([2002:a17:90a:d408:b0:2fa:b84:b308]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2f84:b0:2fe:8c08:88c6 with SMTP id 98e67ed59e1d1-301bde53e35mr11107321a91.7.1742480429675; Thu, 20 Mar 2025 07:20:29 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 20 Mar 2025 07:20:22 -0700 In-Reply-To: <20250320142022.766201-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250320142022.766201-1-seanjc@google.com> X-Mailer: git-send-email 2.49.0.395.g12beb8f557-goog Message-ID: <20250320142022.766201-4-seanjc@google.com> Subject: [PATCH v2 3/3] KVM: x86: Add a module param to control and enumerate device posted IRQs From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a module param to allow disabling device posted interrupts without having to sacrifice all of APICv/AVIC, and to also effectively enumerate to userspace whether or not KVM may be utilizing device posted IRQs. Disabling device posted interrupts is very desirable for testing, and can even be desirable for production environments, e.g. if the host kernel wants to interpose on device interrupts. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/x86.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_hos= t.h index d881e7d276b1..bf11c5ee50cb 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1922,6 +1922,7 @@ struct kvm_arch_async_pf { extern u32 __read_mostly kvm_nr_uret_msrs; extern bool __read_mostly allow_smaller_maxphyaddr; extern bool __read_mostly enable_apicv; +extern bool __read_mostly enable_device_posted_irqs; extern struct kvm_x86_ops kvm_x86_ops; =20 #define kvm_x86_call(func) static_call(kvm_x86_##func) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index f76d655dc9a8..e7eb2198db26 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -227,6 +227,10 @@ EXPORT_SYMBOL_GPL(allow_smaller_maxphyaddr); bool __read_mostly enable_apicv =3D true; EXPORT_SYMBOL_GPL(enable_apicv); =20 +bool __read_mostly enable_device_posted_irqs =3D true; +module_param(enable_device_posted_irqs, bool, 0444); +EXPORT_SYMBOL_GPL(enable_device_posted_irqs); + const struct _kvm_stats_desc kvm_vm_stats_desc[] =3D { KVM_GENERIC_VM_STATS(), STATS_DESC_COUNTER(VM, mmu_shadow_zapped), @@ -9772,6 +9776,9 @@ int kvm_x86_vendor_init(struct kvm_x86_init_ops *ops) if (r !=3D 0) goto out_mmu_exit; =20 + enable_device_posted_irqs &=3D enable_apicv && + irq_remapping_cap(IRQ_POSTING_CAP); + kvm_ops_update(ops); =20 for_each_online_cpu(cpu) { @@ -13552,7 +13559,7 @@ EXPORT_SYMBOL_GPL(kvm_arch_has_noncoherent_dma); =20 bool kvm_arch_has_irq_bypass(void) { - return enable_apicv && irq_remapping_cap(IRQ_POSTING_CAP); + return enable_device_posted_irqs; } EXPORT_SYMBOL_GPL(kvm_arch_has_irq_bypass); =20 --=20 2.49.0.395.g12beb8f557-goog