1 | Add a module param, enable_device_posted_irqs, to control and enumerate | 1 | Add a module param, enable_device_posted_irqs, to control and enumerate |
---|---|---|---|
2 | KVM support for device posted IRQs. | 2 | KVM support for device posted IRQs. |
3 | 3 | ||
4 | v3: | ||
5 | - Put the module param in vendor code to avoid issue with reloading vendor | ||
6 | modules, and to match enable_apicv (and enable_ipiv in the future). | ||
7 | - Fix a shortlog typo. [Jim] | ||
8 | |||
4 | v2: | 9 | v2: |
10 | - https://lore.kernel.org/all/20250320142022.766201-1-seanjc@google.com | ||
5 | - Add prep patches to use kvm_arch_has_irq_bypass() in vendor code when | 11 | - Add prep patches to use kvm_arch_has_irq_bypass() in vendor code when |
6 | querying support IRQ bypass, a.k.a. device posted IRQs, so as not to | 12 | querying support IRQ bypass, a.k.a. device posted IRQs, so as not to |
7 | unexpectedly introduce a (desired) dependency on enable_apicv. [Yosry] | 13 | unexpectedly introduce a (desired) dependency on enable_apicv. [Yosry] |
8 | - Use "&=" when constraining enable_device_posted_irqs based on APICv | 14 | - Use "&=" when constraining enable_device_posted_irqs based on APICv |
9 | and IOMMU posting support. [Yosry] | 15 | and IOMMU posting support. [Yosry] |
10 | 16 | ||
11 | v1: https://lore.kernel.org/all/20250315025615.2367411-1-seanjc@google.com | 17 | v1: https://lore.kernel.org/all/20250315025615.2367411-1-seanjc@google.com |
12 | 18 | ||
13 | |||
14 | Sean Christopherson (3): | 19 | Sean Christopherson (3): |
15 | KVM: VMX: Don't send UNBLOCK when starting device assignment without | 20 | KVM: VMX: Don't send UNBLOCK when starting device assignment without |
16 | APICv | 21 | APICv |
17 | KVM: SVM: Don't update IRTEs if APICv/AVIC is disable | 22 | KVM: SVM: Don't update IRTEs if APICv/AVIC is disabled |
18 | KVM: x86: Add a module param to control and enumerate device posted | 23 | KVM: x86: Add module param to control and enumerate device posted IRQs |
19 | IRQs | ||
20 | 24 | ||
21 | arch/x86/include/asm/kvm_host.h | 1 + | 25 | arch/x86/include/asm/kvm_host.h | 1 + |
22 | arch/x86/kvm/svm/avic.c | 3 +-- | 26 | arch/x86/kvm/svm/avic.c | 3 +-- |
23 | arch/x86/kvm/vmx/posted_intr.c | 7 +++---- | 27 | arch/x86/kvm/svm/svm.c | 2 ++ |
24 | arch/x86/kvm/x86.c | 10 +++++++++- | 28 | arch/x86/kvm/vmx/posted_intr.c | 7 +++---- |
25 | 4 files changed, 14 insertions(+), 7 deletions(-) | 29 | arch/x86/kvm/vmx/vmx.c | 2 ++ |
30 | arch/x86/kvm/x86.c | 9 ++++++++- | ||
31 | 6 files changed, 17 insertions(+), 7 deletions(-) | ||
26 | 32 | ||
27 | 33 | ||
28 | base-commit: c9ea48bb6ee6b28bbc956c1e8af98044618fed5e | 34 | base-commit: 782f9feaa9517caf33186dcdd6b50a8f770ed29b |
29 | -- | 35 | -- |
30 | 2.49.0.395.g12beb8f557-goog | 36 | 2.49.0.472.ge94155a9ec-goog | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
50 | +EXPORT_SYMBOL_GPL(kvm_arch_has_irq_bypass); | 50 | +EXPORT_SYMBOL_GPL(kvm_arch_has_irq_bypass); |
51 | 51 | ||
52 | int kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *cons, | 52 | int kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *cons, |
53 | struct irq_bypass_producer *prod) | 53 | struct irq_bypass_producer *prod) |
54 | -- | 54 | -- |
55 | 2.49.0.395.g12beb8f557-goog | 55 | 2.49.0.472.ge94155a9ec-goog | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
7 | 7 | ||
8 | Opportunsitically kvm_arch_has_irq_bypass() to query for APICv/AVIC, so | 8 | Opportunsitically kvm_arch_has_irq_bypass() to query for APICv/AVIC, so |
9 | so that all checks in KVM x86 incorporate the same information. | 9 | so that all checks in KVM x86 incorporate the same information. |
10 | 10 | ||
11 | Cc: Yosry Ahmed <yosry.ahmed@linux.dev> | 11 | Cc: Yosry Ahmed <yosry.ahmed@linux.dev> |
12 | Cc: Jim Mattson <jmattson@google.com> | ||
12 | Signed-off-by: Sean Christopherson <seanjc@google.com> | 13 | Signed-off-by: Sean Christopherson <seanjc@google.com> |
13 | --- | 14 | --- |
14 | arch/x86/kvm/svm/avic.c | 3 +-- | 15 | arch/x86/kvm/svm/avic.c | 3 +-- |
15 | 1 file changed, 1 insertion(+), 2 deletions(-) | 16 | 1 file changed, 1 insertion(+), 2 deletions(-) |
16 | 17 | ||
... | ... | ||
27 | + if (!kvm_arch_has_assigned_device(kvm) || !kvm_arch_has_irq_bypass()) | 28 | + if (!kvm_arch_has_assigned_device(kvm) || !kvm_arch_has_irq_bypass()) |
28 | return 0; | 29 | return 0; |
29 | 30 | ||
30 | pr_debug("SVM: %s: host_irq=%#x, guest_irq=%#x, set=%#x\n", | 31 | pr_debug("SVM: %s: host_irq=%#x, guest_irq=%#x, set=%#x\n", |
31 | -- | 32 | -- |
32 | 2.49.0.395.g12beb8f557-goog | 33 | 2.49.0.472.ge94155a9ec-goog | diff view generated by jsdifflib |
1 | Add a module param to allow disabling device posted interrupts without | 1 | Add a module param to each KVM vendor module to allow disabling device |
---|---|---|---|
2 | having to sacrifice all of APICv/AVIC, and to also effectively enumerate | 2 | posted interrupts without having to sacrifice all of APICv/AVIC, and to |
3 | to userspace whether or not KVM may be utilizing device posted IRQs. | 3 | also effectively enumerate to userspace whether or not KVM may be |
4 | Disabling device posted interrupts is very desirable for testing, and can | 4 | utilizing device posted IRQs. Disabling device posted interrupts is |
5 | even be desirable for production environments, e.g. if the host kernel | 5 | very desirable for testing, and can even be desirable for production |
6 | wants to interpose on device interrupts. | 6 | environments, e.g. if the host kernel wants to interpose on device |
7 | interrupts. | ||
8 | |||
9 | Put the module param in kvm-{amd,intel}.ko instead of kvm.ko to match | ||
10 | the overall APICv/AVIC controls, and to avoid complications with said | ||
11 | controls. E.g. if the param is in kvm.ko, KVM needs to be snapshot the | ||
12 | original user-defined value to play nice with a vendor module being | ||
13 | reloaded with different enable_apicv settings. | ||
7 | 14 | ||
8 | Signed-off-by: Sean Christopherson <seanjc@google.com> | 15 | Signed-off-by: Sean Christopherson <seanjc@google.com> |
9 | --- | 16 | --- |
10 | arch/x86/include/asm/kvm_host.h | 1 + | 17 | arch/x86/include/asm/kvm_host.h | 1 + |
11 | arch/x86/kvm/x86.c | 9 ++++++++- | 18 | arch/x86/kvm/svm/svm.c | 2 ++ |
12 | 2 files changed, 9 insertions(+), 1 deletion(-) | 19 | arch/x86/kvm/vmx/vmx.c | 2 ++ |
20 | arch/x86/kvm/x86.c | 8 +++++++- | ||
21 | 4 files changed, 12 insertions(+), 1 deletion(-) | ||
13 | 22 | ||
14 | diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h | 23 | diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h |
15 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/arch/x86/include/asm/kvm_host.h | 25 | --- a/arch/x86/include/asm/kvm_host.h |
17 | +++ b/arch/x86/include/asm/kvm_host.h | 26 | +++ b/arch/x86/include/asm/kvm_host.h |
... | ... | ||
21 | extern bool __read_mostly enable_apicv; | 30 | extern bool __read_mostly enable_apicv; |
22 | +extern bool __read_mostly enable_device_posted_irqs; | 31 | +extern bool __read_mostly enable_device_posted_irqs; |
23 | extern struct kvm_x86_ops kvm_x86_ops; | 32 | extern struct kvm_x86_ops kvm_x86_ops; |
24 | 33 | ||
25 | #define kvm_x86_call(func) static_call(kvm_x86_##func) | 34 | #define kvm_x86_call(func) static_call(kvm_x86_##func) |
35 | diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/arch/x86/kvm/svm/svm.c | ||
38 | +++ b/arch/x86/kvm/svm/svm.c | ||
39 | @@ -XXX,XX +XXX,XX @@ module_param(tsc_scaling, int, 0444); | ||
40 | static bool avic; | ||
41 | module_param(avic, bool, 0444); | ||
42 | |||
43 | +module_param(enable_device_posted_irqs, bool, 0444); | ||
44 | + | ||
45 | bool __read_mostly dump_invalid_vmcb; | ||
46 | module_param(dump_invalid_vmcb, bool, 0644); | ||
47 | |||
48 | diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/arch/x86/kvm/vmx/vmx.c | ||
51 | +++ b/arch/x86/kvm/vmx/vmx.c | ||
52 | @@ -XXX,XX +XXX,XX @@ module_param(enable_apicv, bool, 0444); | ||
53 | bool __read_mostly enable_ipiv = true; | ||
54 | module_param(enable_ipiv, bool, 0444); | ||
55 | |||
56 | +module_param(enable_device_posted_irqs, bool, 0444); | ||
57 | + | ||
58 | /* | ||
59 | * If nested=1, nested virtualization is supported, i.e., guests may use | ||
60 | * VMX and be a hypervisor for its own guests. If nested=0, guests may not | ||
26 | diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c | 61 | diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c |
27 | index XXXXXXX..XXXXXXX 100644 | 62 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/arch/x86/kvm/x86.c | 63 | --- a/arch/x86/kvm/x86.c |
29 | +++ b/arch/x86/kvm/x86.c | 64 | +++ b/arch/x86/kvm/x86.c |
30 | @@ -XXX,XX +XXX,XX @@ EXPORT_SYMBOL_GPL(allow_smaller_maxphyaddr); | 65 | @@ -XXX,XX +XXX,XX @@ EXPORT_SYMBOL_GPL(allow_smaller_maxphyaddr); |
31 | bool __read_mostly enable_apicv = true; | 66 | bool __read_mostly enable_apicv = true; |
32 | EXPORT_SYMBOL_GPL(enable_apicv); | 67 | EXPORT_SYMBOL_GPL(enable_apicv); |
33 | 68 | ||
34 | +bool __read_mostly enable_device_posted_irqs = true; | 69 | +bool __read_mostly enable_device_posted_irqs = true; |
35 | +module_param(enable_device_posted_irqs, bool, 0444); | ||
36 | +EXPORT_SYMBOL_GPL(enable_device_posted_irqs); | 70 | +EXPORT_SYMBOL_GPL(enable_device_posted_irqs); |
37 | + | 71 | + |
38 | const struct _kvm_stats_desc kvm_vm_stats_desc[] = { | 72 | const struct _kvm_stats_desc kvm_vm_stats_desc[] = { |
39 | KVM_GENERIC_VM_STATS(), | 73 | KVM_GENERIC_VM_STATS(), |
40 | STATS_DESC_COUNTER(VM, mmu_shadow_zapped), | 74 | STATS_DESC_COUNTER(VM, mmu_shadow_zapped), |
... | ... | ||
56 | + return enable_device_posted_irqs; | 90 | + return enable_device_posted_irqs; |
57 | } | 91 | } |
58 | EXPORT_SYMBOL_GPL(kvm_arch_has_irq_bypass); | 92 | EXPORT_SYMBOL_GPL(kvm_arch_has_irq_bypass); |
59 | 93 | ||
60 | -- | 94 | -- |
61 | 2.49.0.395.g12beb8f557-goog | 95 | 2.49.0.472.ge94155a9ec-goog | diff view generated by jsdifflib |