From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sean Christopherson Date: Thu, 1 Dec 2022 22:49:06 +0000 Subject: [PATCH v2 21/50] KVM: MIPS: Hardcode callbacks to hardware virtualization extensions In-Reply-To: References: <20221130230934.1014142-1-seanjc@google.com> <20221130230934.1014142-22-seanjc@google.com> Message-ID: List-Id: To: kvm-riscv@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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; From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4125AC4321E for ; Thu, 1 Dec 2022 22:49:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id A74144A0DA; Thu, 1 Dec 2022 17:49:18 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IWyQmO7jA+wO; Thu, 1 Dec 2022 17:49:14 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id BFAA94B1AD; Thu, 1 Dec 2022 17:49:14 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id CF5154A0D8 for ; Thu, 1 Dec 2022 17:49:13 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qHlEd2OpKNOc for ; Thu, 1 Dec 2022 17:49:12 -0500 (EST) Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 908C349E4B for ; Thu, 1 Dec 2022 17:49:12 -0500 (EST) Received: by mail-pj1-f41.google.com with SMTP id e7-20020a17090a77c700b00216928a3917so6595824pjs.4 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=yxRYhqHjA5pD2ouL6Ri6FQIFF22t3y5iR5Q6j3JawBghH5CBjkdpeeLsuW6sncb629 2cdW96ZDVUSpl6ditvWaFoa+3fa4yg43uxmE0/o14ydmhpg3Y2pj5ngxm9xifltQG6H2 lDp9195jEcILeOreSJPRh6ayNDS20LO6quOQIeNOsZYrtqHibcH5NdIxAkqwn1H4/Sgm a+wQyn1g/ITNdx1KJVrwluQdZ+14u/grn72Z2bopbUooRzTP0luGy7BHgVp6sgUX81Sp GURwSoSj13MLBTK90nJ4cO/0Pqw1HX9s3PdCKX7ldk2SyNAk41oFDRbGvR/aOX05eimf FJqA== X-Gm-Message-State: ANoB5pmxrs3esM6spgRD3H2osIhs5shMpCf79qigQAcKa+HUBH7b+KcW EtlYqPHSge25lkujbcWsJF1ujg== X-Google-Smtp-Source: AA0mqf4Wt8uYV/bEa16p+0WrrISPwxZH3fHAX4g+Oh8a2UKzOEMh4LEyPBB3ZTgiAtA3/myS/mdVQA== 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?= 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-Disposition: inline In-Reply-To: Cc: Matthew Rosato , Paul Durrant , Yuan Yao , Paul Walmsley , David Hildenbrand , linux-kernel@vger.kernel.org, Kai Huang , Michael Ellerman , linux-riscv@lists.infradead.org, Claudio Imbrenda , kvmarm@lists.cs.columbia.edu, linux-s390@vger.kernel.org, Janosch Frank , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Christian Borntraeger , Chao Gao , Eric Farman , Albert Ou , kvm@vger.kernel.org, Atish Patra , kvmarm@lists.linux.dev, Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Isaku Yamahata , Fabiano Rosas , linuxppc-dev@lists.ozlabs.org, Cornelia Huck , linux-mips@vger.kernel.org, Palmer Dabbelt , kvm-riscv@lists.infradead.org, Paolo Bonzini , Vitaly Kuznetsov , David Woodhouse X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Thu, Dec 01, 2022, Philippe Mathieu-Daud=E9 wrote: > On 1/12/22 00:09, Sean Christopherson wrote: > > Now that KVM no longer supports trap-and-emulate (see commit 45c7e8af4a= 5e > > "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 support= ed > > 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/k= vm_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; _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EBAA10798 for ; Thu, 1 Dec 2022 22:49:12 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id q17-20020a17090aa01100b002194cba32e9so6626891pjp.1 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=Zs3cjDpOdSGUEaNS0SteV2aDrLjokhvelSUnoKKDmseNKiB8jgi0ZBDyTKOpvkkMLm t4IIUZEoeXLW4wHmQSct8x00WLIU8gRZK6kWac21iePCcYkLEWtEvZ9QzFccN9K1jHFh IAS/1aIoIe2xuAmDyaemC5Ht72plhLfuVu2R5if13EWqdNhxFm+Um+b+EwLH7sgMOmLN CrUgcU7SgyTxRScm8ToRpijNyLxs96hya6zmnzvjEY0nZtJmLWYByulgFHzlVTKclSY3 LcK++X7kkAUBoe3RbzMmshIpGowihbtRN3FFbWPLhLBYtEa4WjCtqSUb/WvthbpWtjNF vhug== X-Gm-Message-State: ANoB5plL/4VNVjgNUO0akVPZCDdNZ/fS3PrSTbvJ3j1/sXl0eHG/de0E eUOih9tTWrVS3chXkWeGpij+sw== X-Google-Smtp-Source: AA0mqf4Wt8uYV/bEa16p+0WrrISPwxZH3fHAX4g+Oh8a2UKzOEMh4LEyPBB3ZTgiAtA3/myS/mdVQA== 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> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Message-ID: <20221201224906.gb2ao3HtAImQztR3qWj-JtBGcvkHW-IS84lMECp-Usg@z> 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; From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1DE3EC4332F for ; Thu, 1 Dec 2022 23:26:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mOs4YBpeKtGtoUaYJPrr4LbgkWxIoR6gEz7M0bGpobE=; b=rKcb+QmmKyKPhF 0uCeDau/JoUb4+c1FMGouNfIxMjCfauA6DZ2jswqSg7GGBKfmRa13w74tZ+ulxuCHWks6iH+oDzpw gME+W7ui1m5Y2QzxOcguY0un7aC391tQW/82GO0UkcB2/su905hMuSHEQ80euYCmXeG3Tse+0s7b6 l2VgK4gOjbnWeXPAxWhf8zB0K5/KJLS56SXP6b+IXj4y1v/uL0eNJXfHUb8hbBZ9Lw3uddjqCKunT prATx4xp01fIkGkku13kjUqUuZAZDtLUpoktye0x1GCdnSX9SnnliWoBfPfNwRQhg32hsWFO52nc/ OkU4Dc34X2wq6QSKM+og==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0swF-00Bf1j-OW; Thu, 01 Dec 2022 23:25:55 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0sMj-00BR3T-43 for linux-riscv@lists.infradead.org; Thu, 01 Dec 2022 22:49:14 +0000 Received: by mail-pj1-x102a.google.com with SMTP id q15so2196433pja.0 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=trQMybY7SabNoR2DzhBzK3qqfURNw70A+2cZChoyjubJ7zMp2xiJX3JHCyQ+J+ZKTG efAh+GXzSB5pUYIhAcm3Di2fWZ/vYgXhovyjHe9XMrRTu++AjuOyD6jiJPBtfqOB2UiG 3J4ZCNIRc+HBbkT9yiOPvqN4I5y5VCrS6qG2zKpFCAf6T4DZJ5+S5bppNX4xqKtWHbiu NvmfPd7y+dsFWIwGoXzYIijXu5QcDDdHq8b0hOceMMFm/F4xC9AazATwh3Xvrgz1TfVD omdJNzr2taSnjxboFYi5KyUioTwF/xk2b6a7fxv2ES+VchnOZX75wdYsNqDl0di2vdrX RTrA== X-Gm-Message-State: ANoB5pms4mhEuDsHX19lahmfgug0XcKyvjo9/ORxmGEKBNkYk0dfVNWh 0x3ATLEA3IOi1OrPyRBUcA79DA== X-Google-Smtp-Source: AA0mqf4Wt8uYV/bEa16p+0WrrISPwxZH3fHAX4g+Oh8a2UKzOEMh4LEyPBB3ZTgiAtA3/myS/mdVQA== 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-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221201_144913_190798_646974DD X-CRM114-Status: GOOD ( 20.23 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Thu, Dec 01, 2022, Philippe Mathieu-Daud=E9 wrote: > On 1/12/22 00:09, Sean Christopherson wrote: > > Now that KVM no longer supports trap-and-emulate (see commit 45c7e8af4a= 5e > > "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 support= ed > > 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/k= vm_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; _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E72FC4332F for ; Thu, 1 Dec 2022 22:50:12 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4NNWVp5sFMz3bgD for ; Fri, 2 Dec 2022 09:50:10 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=Lo1VVBU0; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=google.com (client-ip=2607:f8b0:4864:20::1029; helo=mail-pj1-x1029.google.com; envelope-from=seanjc@google.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=Lo1VVBU0; dkim-atps=neutral Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4NNWTl4qp7z3bPR for ; Fri, 2 Dec 2022 09:49:14 +1100 (AEDT) Received: by mail-pj1-x1029.google.com with SMTP id l22-20020a17090a3f1600b00212fbbcfb78so6599780pjc.3 for ; Thu, 01 Dec 2022 14:49:14 -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=flxS9u4Vg0uyPFXK3lQPRcvhB8fMVn4IRQeP1xsUrwo/qJ0p10YXxRh2hm8HRIb8G9 whaTPRhKyM6L/C/8GsSeUFYJqbtTVLQ1MMmINwrHt7ZX7jdsx/hIh06ENIj239gusOfT geQQ/g4cGdENP/8x66BUZOwyS0ZR+6fy/swm+7oefepkWmxBJ+hYNVR4K8CkdfEhPqdb WhZ9jJzQj3SGDc/qgSf3ziiBVSOrZaSBUsFynmxa+Gy1luDUysFuaAcRYsgjJyXBVuWW Mjc/A6iIbsCyJdZw0FKe5xQK7e03mvgoIsIMy5E4sElPdQ9OtFVPA774R169s4TA4wjO /DCg== X-Gm-Message-State: ANoB5plIjc+gLaE7EmYNtQcSmeFJOVEvWpeh6v1hQyiK8Wtoze9facA2 FSWJxjGBP81qrsTg2EQ26xKhjg== X-Google-Smtp-Source: AA0mqf4Wt8uYV/bEa16p+0WrrISPwxZH3fHAX4g+Oh8a2UKzOEMh4LEyPBB3ZTgiAtA3/myS/mdVQA== 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?= 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-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthew Rosato , Paul Durrant , Yuan Yao , Paul Walmsley , David Hildenbrand , linux-kernel@vger.kernel.org, Kai Huang , linux-riscv@lists.infradead.org, Claudio Imbrenda , kvmarm@lists.cs.columbia.edu, linux-s390@vger.kernel.org, Janosch Frank , Marc Zyngier , Huacai Chen , Aleksandar Markovic , James Morse , Christian Borntraeger , Chao Gao , Eric Farman , Albert Ou , Suzuki K Poulose , kvm@vger.kernel.org, Atish Patra , kvmarm@lists.linux.dev, Thomas Gleixner , Alexandru Elisei , linux-arm-kernel@lists.infradead.org, Isaku Yamahata , Fabiano Rosas , linuxppc-dev@lists.ozlabs.org, Cornelia Huck , linux-mips@vger.kernel.org, Oliver Upton , Palmer Dabbelt , kvm-riscv@lists.infradead.org, Anup Patel , Paolo Bonzini , Vitaly Kuznetsov , David Woodhouse Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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; From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 88347C3A5A7 for ; Thu, 1 Dec 2022 23:27:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tMfp9ejIYmd8E1nihrFPBoYlNvC6iq3W1PJ8XHT1ZLI=; b=OUQ0lICKjSahDH JrxgfnBog3HoY+xaK4Dj3uehPS3FWJuVAPsi8zE4jYQ83+KpoQl/sN8aceI6quAvbgsQoHopSWTnJ GCIJ/kcnTxqp+hNSFUDdYSFxAyPClI7nF1OFMaGjUjVH9zJTMh1ZRrGq3scvjrAgFnH1ZjlFoff9r xVkbYvJSkX5AIpmB5gwwBIywdKm0SJjAyEH5Nq+6HwOfVQYAgjdiwJxtefvEfe3ESSz3J/gIYduVq W28Jnnq6V2YN+VllfwIA/PDLB7WebDGWujJ2fiJvHRV0+AobKwca4161fhM5hdKyVGvGJXMb12MmS BkNLDkykoIXldDvH4eBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0swO-00Bf4P-Cu; Thu, 01 Dec 2022 23:26:04 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0sMj-00BR3V-4Q for linux-arm-kernel@lists.infradead.org; Thu, 01 Dec 2022 22:49:15 +0000 Received: by mail-pj1-x1031.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso6654268pjt.0 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=moI887TAUhBKgA/0v3HlPyu78LBQyYmzYeTPO+cBgHFXSk75UM+syocWb5HDNTWEP2 V9rgEhVKDKgLcmL6BJAFR5log/sP4QQD+1G00b9waEXvYbGRLlcABPsUt62vfK2ZtUxm v22dpeK6Wdd267O89z4IbNsDkhQIakY6eTASJ0YTo9ivJTpDLF9OwIaDNBgiWGaC/nW2 8eHrcHxme4s3h1LMIXycELy8IBiNOXFxTvEGA8cHzQ0zSNM/9Ikyvuc6uGuaNHniG9J/ +wbk2CxeBgwYSAwNAzr5ZhOYKCzdbaZyP/mLppbt4we6wlG7SaJUAiNFP97c1YkeS++Y +FNg== X-Gm-Message-State: ANoB5pkQ4l1eiN2SpGfJ+CtFAYbv1oBY2gRIpjXL+s4d/uXd5oQuGL5G PLS9jBGXQ9ak26BM4mwpJZpKIg== X-Google-Smtp-Source: AA0mqf4Wt8uYV/bEa16p+0WrrISPwxZH3fHAX4g+Oh8a2UKzOEMh4LEyPBB3ZTgiAtA3/myS/mdVQA== 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-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221201_144913_197879_9CBFD9D2 X-CRM114-Status: GOOD ( 21.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Dec 01, 2022, Philippe Mathieu-Daud=E9 wrote: > On 1/12/22 00:09, Sean Christopherson wrote: > > Now that KVM no longer supports trap-and-emulate (see commit 45c7e8af4a= 5e > > "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 support= ed > > 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/k= vm_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; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel