Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1266025rwb; Thu, 1 Dec 2022 14:59:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf6mXYdrTJO7/F+LhRCuQv+62WOybHAMDG2YhvINrz+WjedBKrAiLZ0HdIE3u+nt+chAP3aW X-Received: by 2002:a17:907:62a8:b0:7c0:c311:3673 with SMTP id nd40-20020a17090762a800b007c0c3113673mr169035ejc.155.1669935561170; Thu, 01 Dec 2022 14:59:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669935561; cv=none; d=google.com; s=arc-20160816; b=nbtjQem6ae4Mt8ZsjTJh7qXEbMrAfckoD8ugkh6FO2MgPQx4OIPCXH5osLEEWSwOim fQjewPKPNLpbxD6BWnSe+V5u+T5HKRa9J6iy/ctHoCovqaAhRBSFX33Uk68oGwP3FDTy PAJR4l7ESYej9Q9F2vFaA6sjuUeoMyO0NCOyybkB5+uV6EXc663NG04rkoMmyfEP76jn 9mPNush4cltjM5ZSKKOsUwaUyFp4A7KqLtl22BNZKRi9h6u8qFjQxkbzT+wbTpfA8fL6 +UGT6ZkoiwohvUn0BbzFnhrOQ2Y7EecU43nGx+oaRKhVyoBmLevrwj0Y8Oz2yHhopUgt ambw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=mKF7ACqUicTgwRFQrz4oBsMFvmn+mRrenbI3VwK9VtA=; b=Ohw/kFmqlSBb+suu/seogfVlbl/EDNX9P7Kyr6/pQovJLKxmqDFmXq1R4/p/W9LKTm M7ONggCsJXpG00SOmlJE0TMufsS60Ff8oWr6V8lcBoddO83VDStSIguxAZg5GZxgzlDd bnN3mBvR8R5gj+kMo8KOOqzS2JsOiIfnU4fNFyt5UEqgcoQdpar0W7di6Nu33WMRE4a+ RWKI89MIW5Pi/RKim8J6jt28BWpQ1XBkpC2CCAryMjG//DgKE7oLuc0xDx9Bp/aVj7D6 7q+CeJZmJBS0m+YdS2nt6KdnLTJLdA3NHEw90wVvbEXIx288rhb9MlPTOhCsIkcY2s+n Jdeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Lo1VVBU0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga10-20020a1709070c0a00b007c0b71da0e2si1786147ejc.814.2022.12.01.14.59.00; Thu, 01 Dec 2022 14:59:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Lo1VVBU0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231740AbiLAWuE (ORCPT + 81 others); Thu, 1 Dec 2022 17:50:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231713AbiLAWtq (ORCPT ); Thu, 1 Dec 2022 17:49:46 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AFF2C7261 for ; Thu, 1 Dec 2022 14:49:12 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id t11-20020a17090a024b00b0021932afece4so6594500pje.5 for ; Thu, 01 Dec 2022 14:49:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=mKF7ACqUicTgwRFQrz4oBsMFvmn+mRrenbI3VwK9VtA=; b=Lo1VVBU0quIBqwSjUL/IX6jsQ3Rcbq3kNXFx1b09LmjnR9bQqqs8Qnjl452IWYkBSY P1KTyvwrHEdLgoshrms0r4SI8z1ngo83OqCHRxrURyBE+yArcM+Cs5TCeq44GobVkF0m IuDj+iWRP2zVVwjI1HJslgwJO64iafu01Owc+4A3/mvkEjyzFr8iFAR19fNs0LBLJTf3 Kg1ZIMc5fZ0ipGhmHdhLOXnD8uVTRyQX02DQttBjsyjAKjRvEJFav2gCuZ5FSQ6cpVhK zD3GLCkmoDFgDHZV7t7XBqH0jElTPRdTcydGeJqtHoccQFH5HqfiAwKx6tg04wXmDFCc QADQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mKF7ACqUicTgwRFQrz4oBsMFvmn+mRrenbI3VwK9VtA=; b=Eft+n45KZBSzyNOlJ+fraRAM+LemmE4oRmzt3YitBqj8wePx3k2CGSbUTp+Xh9hkGt lMtsQzPaMVENgII4GQs7SaqFrNOZe2Q0lGgL8XtAbrAXJVRIgmMWwHC7vv/KcwWjVtJh TJwf2TRtma0Zu5cO+hzLoeBa5ZUEWA6k+xIBp5l37CHrv0kfWNVGewotTiNhArLJUYXm vMJEp4gQzplOQjXXpZoDd8EodXD+MnVh0O2/Adn0WY3yKIibKV477P4jUEv8rvjrdZ5b LpdKbXAwk5F1dgKM6Qp4hs2E9nlb9N5TnG5gG9mfFZDtztizHWwK6DICdCevl2sVGCiN OQ/w== X-Gm-Message-State: ANoB5pkC4TleKw6jKhIrzu8YMit639Ve8rYMiXzRhYJ990jIDmEVegXG 5bUHny7Rz5l8zFeAx5KvEZ/VLA== X-Received: by 2002:a17:903:32ce:b0:189:a0eb:4a26 with SMTP id i14-20020a17090332ce00b00189a0eb4a26mr13829305plr.162.1669934951343; Thu, 01 Dec 2022 14:49:11 -0800 (PST) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id c73-20020a624e4c000000b0056bc742d21esm3854175pfb.176.2022.12.01.14.49.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 14:49:10 -0800 (PST) Date: Thu, 1 Dec 2022 22:49:06 +0000 From: Sean Christopherson To: Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= Cc: Paolo Bonzini , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Matthew Rosato , Eric Farman , Vitaly Kuznetsov , David Woodhouse , Paul Durrant , James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Atish Patra , David Hildenbrand , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Yao , Cornelia Huck , Isaku Yamahata , Fabiano Rosas , Michael Ellerman , Kai Huang , Chao Gao , Thomas Gleixner Subject: Re: [PATCH v2 21/50] KVM: MIPS: Hardcode callbacks to hardware virtualization extensions Message-ID: References: <20221130230934.1014142-1-seanjc@google.com> <20221130230934.1014142-22-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > --- > > 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;