From patchwork Wed Nov 2 23:18:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 14530 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp199934wru; Wed, 2 Nov 2022 16:22:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5AOtsZJCNSX2xShTDqZA+ZVJoM/j5P5kbgJjDnia1KtnmLFw8ZliwpHt47h+sIdYINIUcY X-Received: by 2002:a17:90b:3149:b0:213:63d0:88d6 with SMTP id ip9-20020a17090b314900b0021363d088d6mr28237148pjb.145.1667431355321; Wed, 02 Nov 2022 16:22:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667431355; cv=none; d=google.com; s=arc-20160816; b=miC4QQO+gQDU9pzvrYsmw1SNFNO4vadi1t19a+UOl4rCYq2JG+55oFOUuM3Q4rgrzJ O/D1IzkhffTF9wsLxlwNHnZA0lt8qsgRLXCwi9C7MldOSIAV9+OkdbOydq6W86lI8SX1 HgQVk/QhV5xrY4vYJdhf4FVxD5toLaVFp8QtSm7gDyUIYslLG8XkwqmoasZYVRPTdN50 vwT//hTl64AKIZrI9FYBS/VPoJocUU/VfUDWH7nWS0rUpj2WHtpIPaOyyAwgErStZdio 9y9wxfqjZMDzqnO43FAsaiqy7mMFZIASLIgG0ie2PJYUFd4hXHWcjLNl0VDRsLyIzXTR lV2g== 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=s9AuxTlRjBrfjYkcaQi28he/RkCYbCa6yMT59uzOKa0=; b=GulqreIGZ7IjkAnBf/hSq1BmYNGNhtTFmF6Nm0Y/lOx4fVvCkoPDJbKjm9SEiGuG42 BpOzeu1rtae+51BHLjCVmWMX4KQCwl6ggNXPueLBLqMT8OtaWiB48E1/Mqf3z/Vlx9QF rSjatoD/t9TKZQJJ/2Ei47nw8g/0zsKrEiUE4Jl5PZDccpG5NDT+MIotY5MUPizGi6/F gMNZ+zhcpe04ZOE8z+i5ZXedfDRS2aboPQsfBzTlhFZYm7Teiko1VOlEzxnH2dqJi4bP m92TGzF6e3NlICRBr8YgQTArW00/xlzNqp96uvTEEXW/PS+sxXgGYnI64dguxFv/NnWk 4Rjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ddAfxHTl; 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 h16-20020a170902f55000b001871d062940si15265662plf.400.2022.11.02.16.22.22; Wed, 02 Nov 2022 16:22:35 -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=ddAfxHTl; 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 S231197AbiKBXVz (ORCPT + 99 others); Wed, 2 Nov 2022 19:21:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231280AbiKBXU3 (ORCPT ); Wed, 2 Nov 2022 19:20:29 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4B186431 for ; Wed, 2 Nov 2022 16:19:49 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id e13-20020a17090301cd00b001871e6f8714so216891plh.14 for ; Wed, 02 Nov 2022 16:19:49 -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=s9AuxTlRjBrfjYkcaQi28he/RkCYbCa6yMT59uzOKa0=; b=ddAfxHTlEUHw0qawyyn7Bns3LOyks9re4MtMC6FAIFAvlDf6eK/nu/+/9Fi10x1R6n WWJsCNbWaFv5FoXY2JkfL2gPHfmH7n5Ig/c/8vgYFwan9v+I5VkTcY5cAcyMIsF0YYgl ayeymXyuzlb1ZK6RywTZFK6M2TrYNtbmp52NtBkrAW3CizVOcP2GK1YSKNk0hRzbGX/H t6V+7QqjJlqd98Pv08NBqx2q5El2vxmRcwGZXuIwYC0OoPXag/D+TlMulKYngdYVLuGi IcUk8i0bIt121WR3Ua8dNN2eN53mKcAGIC6t4monNq6evoAdLql3aLFHNiEvl7F6ATwg 1KbQ== 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=s9AuxTlRjBrfjYkcaQi28he/RkCYbCa6yMT59uzOKa0=; b=aQY9PITYwTyAstSESuRzncPG1QTQsxC+2oWcYZZkYX4Jlj2+3lV5MqMA6S7Fzs0fF5 KN511d9f4hvkhQ41Smv7qFGE0p+2di+oKykiMN7l3U+heR9DFlsv6O3Junvp6zdsvHro 3la4kA+STI/xKDNLOhluJh2lCuIR+seOOvO3hDWOSfNfpb3hM1txuWliQkbpRWvctB63 CJVgp0Eymm46C6R/wl0+H1Yr+gKwLcKpIvKMesVz9sZSqKKl4pXE1Zs8VQL/bKjMvwQT WbCmmG30IIoFfAlpkF+RlZ1ZnVYNEFtmN5qcZcXgHt4DWGnVHUv3jBRW2wNrqlxqLenq OCYQ== X-Gm-Message-State: ACrzQf34O0CAasg6NFbgvkS7fmQuKhWED7gIpMAhOIdKSX2AXO+0rFLF lWPTxs1XH7zWtFb5FhBXub0SlB228Lg= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:903:240a:b0:183:6555:7a89 with SMTP id e10-20020a170903240a00b0018365557a89mr27116619plo.68.1667431189462; Wed, 02 Nov 2022 16:19:49 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 2 Nov 2022 23:18:48 +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-22-seanjc@google.com> Subject: [PATCH 21/44] KVM: MIPS: Register die notifier prior to kvm_init() From: Sean Christopherson To: 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 , Sean Christopherson , Vitaly Kuznetsov Cc: 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, Isaku Yamahata , Fabiano Rosas , Michael Ellerman , Chao Gao , Thomas Gleixner , Yuan Yao 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748428500560448472?= X-GMAIL-MSGID: =?utf-8?q?1748428500560448472?= Call kvm_init() only after _all_ setup is complete, as kvm_init() exposes /dev/kvm to userspace and thus allows userspace to create VMs (and call other ioctls). Signed-off-by: Sean Christopherson Reviewed-by: Philippe Mathieu-Daudé --- arch/mips/kvm/mips.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c index 75681281e2df..ae7a24342fdf 100644 --- a/arch/mips/kvm/mips.c +++ b/arch/mips/kvm/mips.c @@ -1640,16 +1640,17 @@ static int __init kvm_mips_init(void) if (ret) return ret; - ret = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE); - - if (ret) - return ret; if (boot_cpu_type() == CPU_LOONGSON64) kvm_priority_to_irq = kvm_loongson3_priority_to_irq; register_die_notifier(&kvm_mips_csr_die_notifier); + ret = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE); + if (ret) { + unregister_die_notifier(&kvm_mips_csr_die_notifier); + return ret; + } return 0; }