Message ID | 20221102231911.3107438-26-seanjc@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp200265wru; Wed, 2 Nov 2022 16:23:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5U5PySqzVtJy2/8YcE7jVmtplQNC5Zxq4TXUujRKXxkZs98bdPORTra8DL3HXhY/Jv213F X-Received: by 2002:a17:903:234f:b0:17f:6711:1f9f with SMTP id c15-20020a170903234f00b0017f67111f9fmr26458763plh.32.1667431406159; Wed, 02 Nov 2022 16:23:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667431406; cv=none; d=google.com; s=arc-20160816; b=UfkyjWFljsktwlm3keQSLXHbA9th8bV7348XRRuGuBmf0x1o1kt6hsCyU1fJAgSPJV gUYhuVBZcqLaop5VcuFudMjRiNY639thFfBeA62DGSOcse6M02CJ/ksNj3AEE3ylIhU9 TcMJAVXujFb/tJ25Aem6k+CeFwU2NiKYOMfZ5iINqP3TjL4WWH9MQdIijj5LljeDutWS 3h7IjsUEvf+Lg1mh8zS18xSCfsCzqjD5acCVTZiNoxBXf8qiqkoAA0+xzAKgMi9vhiPV nYWxnQe5YrQ/zfR2mwmNThosYtB93hAbDhmXjZkOoxXn/bJ74aD8lO/FPO6euP0XfyYl +w/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:dkim-signature; bh=CzSf5zn0WCjHNHnOQoVFnBDZCb0UJEWJAWP5e8x7mpU=; b=w1LBlqczvlmYeRSMhPEKCniM7BQfMn3//mBxdE1pY02gdiHP769z+9ygXnW7sM1Vkd mWqpl8GHvUBXasOO5tItePT3+UDbTJ1qBwR2SjUDG6514hXE+wFAExJhKRyKZxv9tTlR 2R730v1OUfiti+7xq8cHmsdJ/PEPE4HvyPhDO0nraNKjWQybF3RWCBvzIWKJT8LVvSnc 9ZdikLJxPxFR58A7xN1X2k7JAKJypwdNnYwTZ9u8rIHYf/xLMrWWnjH/nIimQapb4f7H UbniYl7oC9B3fOpF53+uL/9UKS2WAb/cJdfsN1ZCPCL/VxOUSVdCChVqH27mRz/tjytZ 0ZyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qayOPbuA; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 19-20020a631153000000b004610dceee7fsi18351051pgr.165.2022.11.02.16.23.12; Wed, 02 Nov 2022 16:23:26 -0700 (PDT) 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=qayOPbuA; 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 S231143AbiKBXWr (ORCPT <rfc822;yves.mi.zy@gmail.com> + 99 others); Wed, 2 Nov 2022 19:22:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbiKBXUo (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 2 Nov 2022 19:20:44 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66F5AAE4E for <linux-kernel@vger.kernel.org>; Wed, 2 Nov 2022 16:19:56 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-352e29ff8c2so501617b3.21 for <linux-kernel@vger.kernel.org>; Wed, 02 Nov 2022 16:19:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=CzSf5zn0WCjHNHnOQoVFnBDZCb0UJEWJAWP5e8x7mpU=; b=qayOPbuABiIuhyUyS81pM4aIXP0zbbDCyOAoStlcDM54io6H46scG/b+AOJZ083vkp 7VUQSDA3F1PV+eczWk9jhX07na0Ee5Y/y96fcuWnjX0SDylBmMM507BoItRwczIvX47w quWZbFbuSFsnuRxvRxHTWN2VK6E9IoRaN3Rn0730zHfCEZF81HBccJpL9kyZIy1KxZA/ 662DkzEQNlhCKGQQORLsI62wqsjL9SN7t5eET3UjVYfrxzuz8jEkm9iuoDgYatGUaOSX hwFfEfHx7Y5bc5lWLW7ELIceyIhTn7UMBpI42o+ooA3Zs7kMfZ0227v/cGHQHHsdYmrl HIHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CzSf5zn0WCjHNHnOQoVFnBDZCb0UJEWJAWP5e8x7mpU=; b=1qC/wyzgLcJ45FRbGUZzdSV7fB5hDf01fHqlP+fgUqOmzibT7pIGHk6RwoudnH5FJr DAUr4GLrDn3tS81y4uLYGqQuzVMaIjhLZWkrCdA9issiOFOMzuWQl2GlEOClKHMqMXFU d6fPHpfKL48jwa+BwxtMvhVFEH0q9E1WoVS4dPCXWeqI0aj2bujIQ2950PKvwYyUToh/ geW9GmvFOmqZ96AZOrl5G3lh/tS/cu9fMj+8/HWAuPzA7cYvTRKe3wxRhd7XZrOm/ZHY RyC2RdwOKN/PTUXfFvuAYyz05Q28q+ICZ3HWXRTNcEiRH1a82tjKpVm29mGLLt+mAhYL xi/w== X-Gm-Message-State: ACrzQf3o2z/dsGEXXjJygSqeCXRa5P6xzlSHsLIciF9snMQBh2v9YiHC L7z42nYTbhvOnMPYm2DgYl5MFcLvlII= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:2544:0:b0:360:c270:15a1 with SMTP id l65-20020a812544000000b00360c27015a1mr24717446ywl.67.1667431196650; Wed, 02 Nov 2022 16:19:56 -0700 (PDT) Reply-To: Sean Christopherson <seanjc@google.com> Date: Wed, 2 Nov 2022 23:18:52 +0000 In-Reply-To: <20221102231911.3107438-1-seanjc@google.com> Mime-Version: 1.0 References: <20221102231911.3107438-1-seanjc@google.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Message-ID: <20221102231911.3107438-26-seanjc@google.com> Subject: [PATCH 25/44] KVM: s390: Do s390 specific init without bouncing through kvm_init() From: Sean Christopherson <seanjc@google.com> To: Paolo Bonzini <pbonzini@redhat.com>, Marc Zyngier <maz@kernel.org>, Huacai Chen <chenhuacai@kernel.org>, Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>, Anup Patel <anup@brainfault.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Christian Borntraeger <borntraeger@linux.ibm.com>, Janosch Frank <frankja@linux.ibm.com>, Claudio Imbrenda <imbrenda@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Sean Christopherson <seanjc@google.com>, Vitaly Kuznetsov <vkuznets@redhat.com> Cc: James Morse <james.morse@arm.com>, Alexandru Elisei <alexandru.elisei@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, Oliver Upton <oliver.upton@linux.dev>, Atish Patra <atishp@atishpatra.org>, David Hildenbrand <david@redhat.com>, 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, Isaku Yamahata <isaku.yamahata@intel.com>, Fabiano Rosas <farosas@linux.ibm.com>, Michael Ellerman <mpe@ellerman.id.au>, Chao Gao <chao.gao@intel.com>, Thomas Gleixner <tglx@linutronix.de>, Yuan Yao <yuan.yao@intel.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748428554338429468?= X-GMAIL-MSGID: =?utf-8?q?1748428554338429468?= |
Series |
KVM: Rework kvm_init() and hardware enabling
|
|
Commit Message
Sean Christopherson
Nov. 2, 2022, 11:18 p.m. UTC
Move the guts of kvm_arch_init() into a new helper, __kvm_s390_init(),
and invoke the new helper directly from kvm_s390_init() instead of
bouncing through kvm_init(). Invoking kvm_arch_init() is the very
first action performed by kvm_init(), i.e. this is a glorified nop.
Moving setup to __kvm_s390_init() will allow tagging more functions as
__init, and emptying kvm_arch_init() will allow dropping the hook
entirely once all architecture implementations are nops.
No functional change intended.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/s390/kvm/kvm-s390.c | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
Comments
On 3/11/22 00:18, Sean Christopherson wrote: > Move the guts of kvm_arch_init() into a new helper, __kvm_s390_init(), > and invoke the new helper directly from kvm_s390_init() instead of > bouncing through kvm_init(). Invoking kvm_arch_init() is the very > first action performed by kvm_init(), i.e. this is a glorified nop. > > Moving setup to __kvm_s390_init() will allow tagging more functions as > __init, and emptying kvm_arch_init() will allow dropping the hook > entirely once all architecture implementations are nops. > > No functional change intended. > > Signed-off-by: Sean Christopherson <seanjc@google.com> > --- > arch/s390/kvm/kvm-s390.c | 29 +++++++++++++++++++++++++---- > 1 file changed, 25 insertions(+), 4 deletions(-) Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
On Wed, 2 Nov 2022 23:18:52 +0000 Sean Christopherson <seanjc@google.com> wrote: > Move the guts of kvm_arch_init() into a new helper, __kvm_s390_init(), > and invoke the new helper directly from kvm_s390_init() instead of > bouncing through kvm_init(). Invoking kvm_arch_init() is the very > first action performed by kvm_init(), i.e. this is a glorified nop. > > Moving setup to __kvm_s390_init() will allow tagging more functions as > __init, and emptying kvm_arch_init() will allow dropping the hook > entirely once all architecture implementations are nops. > > No functional change intended. > > Signed-off-by: Sean Christopherson <seanjc@google.com> > --- > arch/s390/kvm/kvm-s390.c | 29 +++++++++++++++++++++++++---- > 1 file changed, 25 insertions(+), 4 deletions(-) > > diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c > index 7fcd2d3b3558..e1c9980aae78 100644 > --- a/arch/s390/kvm/kvm-s390.c > +++ b/arch/s390/kvm/kvm-s390.c > @@ -461,7 +461,7 @@ static void kvm_s390_cpu_feat_init(void) > */ > } > > -int kvm_arch_init(void *opaque) > +static int __kvm_s390_init(void) > { > int rc = -ENOMEM; > > @@ -519,7 +519,7 @@ int kvm_arch_init(void *opaque) > return rc; > } > > -void kvm_arch_exit(void) > +static void __kvm_s390_exit(void) > { > gmap_unregister_pte_notifier(&gmap_notifier); > gmap_unregister_pte_notifier(&vsie_gmap_notifier); > @@ -533,6 +533,16 @@ void kvm_arch_exit(void) > debug_unregister(kvm_s390_dbf_uv); > } > > +int kvm_arch_init(void *opaque) > +{ > + return 0; > +} > + > +void kvm_arch_exit(void) > +{ > + > +} > + I wonder at this point if it's possible to define kvm_arch_init and kvm_arch_exit directly in kvm_main.c with __weak > /* Section: device related */ > long kvm_arch_dev_ioctl(struct file *filp, > unsigned int ioctl, unsigned long arg) > @@ -5634,7 +5644,7 @@ static inline unsigned long nonhyp_mask(int i) > > static int __init kvm_s390_init(void) > { > - int i; > + int i, r; > > if (!sclp.has_sief2) { > pr_info("SIE is not available\n"); > @@ -5650,12 +5660,23 @@ static int __init kvm_s390_init(void) > kvm_s390_fac_base[i] |= > stfle_fac_list[i] & nonhyp_mask(i); > > - return kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE); > + r = __kvm_s390_init(); > + if (r) > + return r; > + > + r = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE); > + if (r) { > + __kvm_s390_exit(); > + return r; > + } > + return 0; > } > > static void __exit kvm_s390_exit(void) > { > kvm_exit(); > + > + __kvm_s390_exit(); > } > > module_init(kvm_s390_init);
On Thu, 3 Nov 2022 13:44:15 +0100 Claudio Imbrenda <imbrenda@linux.ibm.com> wrote: > On Wed, 2 Nov 2022 23:18:52 +0000 > Sean Christopherson <seanjc@google.com> wrote: > > > Move the guts of kvm_arch_init() into a new helper, __kvm_s390_init(), > > and invoke the new helper directly from kvm_s390_init() instead of > > bouncing through kvm_init(). Invoking kvm_arch_init() is the very > > first action performed by kvm_init(), i.e. this is a glorified nop. > > > > Moving setup to __kvm_s390_init() will allow tagging more functions as > > __init, and emptying kvm_arch_init() will allow dropping the hook > > entirely once all architecture implementations are nops. > > > > No functional change intended. > > > > Signed-off-by: Sean Christopherson <seanjc@google.com> > > --- > > arch/s390/kvm/kvm-s390.c | 29 +++++++++++++++++++++++++---- > > 1 file changed, 25 insertions(+), 4 deletions(-) > > > > diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c > > index 7fcd2d3b3558..e1c9980aae78 100644 > > --- a/arch/s390/kvm/kvm-s390.c > > +++ b/arch/s390/kvm/kvm-s390.c > > @@ -461,7 +461,7 @@ static void kvm_s390_cpu_feat_init(void) > > */ > > } > > > > -int kvm_arch_init(void *opaque) > > +static int __kvm_s390_init(void) > > { > > int rc = -ENOMEM; > > > > @@ -519,7 +519,7 @@ int kvm_arch_init(void *opaque) > > return rc; > > } > > > > -void kvm_arch_exit(void) > > +static void __kvm_s390_exit(void) > > { > > gmap_unregister_pte_notifier(&gmap_notifier); > > gmap_unregister_pte_notifier(&vsie_gmap_notifier); > > @@ -533,6 +533,16 @@ void kvm_arch_exit(void) > > debug_unregister(kvm_s390_dbf_uv); > > } > > > > +int kvm_arch_init(void *opaque) > > +{ > > + return 0; > > +} > > + > > +void kvm_arch_exit(void) > > +{ > > + > > +} > > + > > I wonder at this point if it's possible to define kvm_arch_init and > kvm_arch_exit directly in kvm_main.c with __weak ah, nevermind, you get rid of them completely in the next patch > > > /* Section: device related */ > > long kvm_arch_dev_ioctl(struct file *filp, > > unsigned int ioctl, unsigned long arg) > > @@ -5634,7 +5644,7 @@ static inline unsigned long nonhyp_mask(int i) > > > > static int __init kvm_s390_init(void) > > { > > - int i; > > + int i, r; > > > > if (!sclp.has_sief2) { > > pr_info("SIE is not available\n"); > > @@ -5650,12 +5660,23 @@ static int __init kvm_s390_init(void) > > kvm_s390_fac_base[i] |= > > stfle_fac_list[i] & nonhyp_mask(i); > > > > - return kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE); > > + r = __kvm_s390_init(); > > + if (r) > > + return r; > > + > > + r = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE); > > + if (r) { > > + __kvm_s390_exit(); > > + return r; > > + } > > + return 0; > > } > > > > static void __exit kvm_s390_exit(void) > > { > > kvm_exit(); > > + > > + __kvm_s390_exit(); > > } > > > > module_init(kvm_s390_init); >
On Wed, 2022-11-02 at 23:18 +0000, Sean Christopherson wrote: > Move the guts of kvm_arch_init() into a new helper, > __kvm_s390_init(), > and invoke the new helper directly from kvm_s390_init() instead of > bouncing through kvm_init(). Invoking kvm_arch_init() is the very > first action performed by kvm_init(), i.e. this is a glorified nop. > > Moving setup to __kvm_s390_init() will allow tagging more functions > as > __init, and emptying kvm_arch_init() will allow dropping the hook > entirely once all architecture implementations are nops. > > No functional change intended. > > Signed-off-by: Sean Christopherson <seanjc@google.com> > --- > arch/s390/kvm/kvm-s390.c | 29 +++++++++++++++++++++++++---- > 1 file changed, 25 insertions(+), 4 deletions(-) Reviewed-by: Eric Farman <farman@linux.ibm.com>
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 7fcd2d3b3558..e1c9980aae78 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -461,7 +461,7 @@ static void kvm_s390_cpu_feat_init(void) */ } -int kvm_arch_init(void *opaque) +static int __kvm_s390_init(void) { int rc = -ENOMEM; @@ -519,7 +519,7 @@ int kvm_arch_init(void *opaque) return rc; } -void kvm_arch_exit(void) +static void __kvm_s390_exit(void) { gmap_unregister_pte_notifier(&gmap_notifier); gmap_unregister_pte_notifier(&vsie_gmap_notifier); @@ -533,6 +533,16 @@ void kvm_arch_exit(void) debug_unregister(kvm_s390_dbf_uv); } +int kvm_arch_init(void *opaque) +{ + return 0; +} + +void kvm_arch_exit(void) +{ + +} + /* Section: device related */ long kvm_arch_dev_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) @@ -5634,7 +5644,7 @@ static inline unsigned long nonhyp_mask(int i) static int __init kvm_s390_init(void) { - int i; + int i, r; if (!sclp.has_sief2) { pr_info("SIE is not available\n"); @@ -5650,12 +5660,23 @@ static int __init kvm_s390_init(void) kvm_s390_fac_base[i] |= stfle_fac_list[i] & nonhyp_mask(i); - return kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE); + r = __kvm_s390_init(); + if (r) + return r; + + r = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE); + if (r) { + __kvm_s390_exit(); + return r; + } + return 0; } static void __exit kvm_s390_exit(void) { kvm_exit(); + + __kvm_s390_exit(); } module_init(kvm_s390_init);