[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <04886fe0-a796-4265-abd9-56bfe3a0aa0c@intel.com>
Date: Fri, 19 Dec 2025 10:48:38 -0800
From: Dave Hansen <dave.hansen@...el.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>,
x86@...nel.org, Kiryl Shutsemau <kas@...nel.org>,
Paolo Bonzini <pbonzini@...hat.com>, linux-kernel@...r.kernel.org,
linux-coco@...ts.linux.dev, kvm@...r.kernel.org,
Chao Gao <chao.gao@...el.com>, Dan Williams <dan.j.williams@...el.com>
Subject: Re: [PATCH v2 2/7] KVM: x86: Extract VMXON and EFER.SVME enablement
to kernel
On 12/19/25 10:35, Sean Christopherson wrote:
> I haven't tested yet, but I've got this:
>
> struct x86_virt_ops {
> int feature;
> int (*enable_virtualization_cpu)(void);
> int (*disable_virtualization_cpu)(void);
> void (*emergency_disable_virtualization_cpu)(void);
> };
> static struct x86_virt_ops virt_ops __ro_after_init;
>
> and then usage like:
>
> int x86_virt_get_ref(int feat)
> {
> int r;
>
> if (!virt_ops.feature || virt_ops.feature != feat)
> return -EOPNOTSUPP;
>
> if (this_cpu_inc_return(virtualization_nr_users) > 1)
> return 0;
>
> r = virt_ops.enable_virtualization_cpu();
> if (r)
> WARN_ON_ONCE(this_cpu_dec_return(virtualization_nr_users));
>
> return r;
> }
> EXPORT_SYMBOL_GPL(x86_virt_get_ref);
Yeah, that's much easier to follow, and fixes the naming collision thanks!
Powered by blists - more mailing lists