lkml.org 
[lkml]   [2022]   [Dec]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 21/50] KVM: MIPS: Hardcode callbacks to hardware virtualization extensions
On Thu, Dec 01, 2022, Philippe Mathieu-Daudé wrote:
> On 1/12/22 00:09, Sean Christopherson wrote:
> > Now that KVM no longer supports trap-and-emulate (see commit 45c7e8af4a5e
> > "MIPS: Remove KVM_TE support"), hardcode the MIPS callbacks to the
> > virtualization callbacks.
> >
> > Harcoding the callbacks eliminates the technically-unnecessary check on
> > non-NULL kvm_mips_callbacks in kvm_arch_init(). MIPS has never supported
> > multiple in-tree modules, i.e. barring an out-of-tree module, where
> > copying and renaming kvm.ko counts as "out-of-tree", KVM could never
> > encounter a non-NULL set of callbacks during module init.
> >
> > The callback check is also subtly broken, as it is not thread safe,
> > i.e. if there were multiple modules, loading both concurrently would
> > create a race between checking and setting kvm_mips_callbacks.
> >
> > Given that out-of-tree shenanigans are not the kernel's responsibility,
> > hardcode the callbacks to simplify the code.
> >
> > Signed-off-by: Sean Christopherson <seanjc@google.com>
> > ---
> > arch/mips/include/asm/kvm_host.h | 2 +-
> > arch/mips/kvm/Makefile | 2 +-
> > arch/mips/kvm/callback.c | 14 --------------
> > arch/mips/kvm/mips.c | 9 ++-------
> > arch/mips/kvm/vz.c | 7 ++++---
> > 5 files changed, 8 insertions(+), 26 deletions(-)
> > delete mode 100644 arch/mips/kvm/callback.c
> >
> > diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h
> > index 28f0ba97db71..2803c9c21ef9 100644
> > --- a/arch/mips/include/asm/kvm_host.h
> > +++ b/arch/mips/include/asm/kvm_host.h
> > @@ -758,7 +758,7 @@ struct kvm_mips_callbacks {
> > void (*vcpu_reenter)(struct kvm_vcpu *vcpu);
> > };
> > extern struct kvm_mips_callbacks *kvm_mips_callbacks;
>
> IIUC we could even constify this pointer.

Good point. Protecting the pointer itself is a bit gross, but it is a nice
stopgap until the callbacks are gone. I'll fold this in. Thanks!

extern const struct kvm_mips_callbacks * const kvm_mips_callbacks;

\
 
 \ /
  Last update: 2022-12-01 23:51    [W:0.759 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site