[PATCH v8 38/55] i386/tdx: Set and check kernel_irqchip mode for TDX

Xiaoyao Li posted 55 patches 3 days, 16 hours ago
[PATCH v8 38/55] i386/tdx: Set and check kernel_irqchip mode for TDX
Posted by Xiaoyao Li 3 days, 16 hours ago
KVM mandates kernel_irqchip to be split mode.

Set it to split mode automatically when users don't provide an explicit
value, otherwise check it to be the split mode.

Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
 target/i386/kvm/tdx.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
index 0d30506c2021..4128f27d6b64 100644
--- a/target/i386/kvm/tdx.c
+++ b/target/i386/kvm/tdx.c
@@ -16,6 +16,7 @@
 #include "qapi/error.h"
 #include "qom/object_interfaces.h"
 #include "crypto/hash.h"
+#include "system/kvm_int.h"
 #include "system/runstate.h"
 #include "system/system.h"
 #include "exec/ramblock.h"
@@ -390,6 +391,13 @@ static int tdx_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
         return -EINVAL;
     }
 
+    if (kvm_state->kernel_irqchip_split == ON_OFF_AUTO_AUTO ) {
+        kvm_state->kernel_irqchip_split = ON_OFF_AUTO_ON;
+    } else if(kvm_state->kernel_irqchip_split != ON_OFF_AUTO_ON) {
+        error_setg(errp, "TDX VM requires kernel_irqchip to be split");
+        return -EINVAL;
+    }
+
     if (!tdx_caps) {
         r = get_tdx_capabilities(errp);
         if (r) {
-- 
2.34.1


Re: [PATCH v8 38/55] i386/tdx: Set and check kernel_irqchip mode for TDX
Posted by Daniel P. Berrangé 2 days, 18 hours ago
On Tue, Apr 01, 2025 at 09:01:48AM -0400, Xiaoyao Li wrote:
> KVM mandates kernel_irqchip to be split mode.
> 
> Set it to split mode automatically when users don't provide an explicit
> value, otherwise check it to be the split mode.
> 
> Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
> ---
>  target/i386/kvm/tdx.c | 8 ++++++++
>  1 file changed, 8 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


> diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
> index 0d30506c2021..4128f27d6b64 100644
> --- a/target/i386/kvm/tdx.c
> +++ b/target/i386/kvm/tdx.c
> @@ -16,6 +16,7 @@
>  #include "qapi/error.h"
>  #include "qom/object_interfaces.h"
>  #include "crypto/hash.h"
> +#include "system/kvm_int.h"
>  #include "system/runstate.h"
>  #include "system/system.h"
>  #include "exec/ramblock.h"
> @@ -390,6 +391,13 @@ static int tdx_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
>          return -EINVAL;
>      }
>  
> +    if (kvm_state->kernel_irqchip_split == ON_OFF_AUTO_AUTO ) {

Nitpick, no need for a space before the ')' ...

> +        kvm_state->kernel_irqchip_split = ON_OFF_AUTO_ON;
> +    } else if(kvm_state->kernel_irqchip_split != ON_OFF_AUTO_ON) {

..and need a space between 'if' and '('

> +        error_setg(errp, "TDX VM requires kernel_irqchip to be split");
> +        return -EINVAL;
> +    }
> +

Note for self - 'tdx_kvm_init' is called by 'confidential_guest_kvm_init',
which is called by 'kvm_arch_init', which is called by 'kvm_init' *before*
it processes "kvm_state->kernel_irqchip_split == ON_OFF_AUTO_AUTO" to set
the default. So this change is correctly taking priority over the default
behaviour.

>      if (!tdx_caps) {
>          r = get_tdx_capabilities(errp);
>          if (r) {
> -- 
> 2.34.1
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|