Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1789545rwn; Fri, 9 Sep 2022 04:14:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR7i5Vp3swrP3JgI3WDZYwolsvv3WC6d29i8Fb37whQ7Yz5+4IQ5HDNcjjDoUVZsjVhBS2a1 X-Received: by 2002:a63:e442:0:b0:438:7919:adf with SMTP id i2-20020a63e442000000b0043879190adfmr4114797pgk.4.1662722049811; Fri, 09 Sep 2022 04:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662722049; cv=none; d=google.com; s=arc-20160816; b=ORdwFehxPRTvyaQ6nYZ8m2wjJxVxcHNA+6vMg1/lcUPUKhHvZeo4LSUZv02EMPFZ85 5hN2gPKxvEYL0rOipwQvjKDrDGr3v113Fg4QCYq45PpoB8iQG29qHrCKgJGeDR7Hxydy oJKBy8wiAFoVu7EalJeSwiKBQyOh2FK22PB54GIMBtHGBh/x16FAjuoa03EEd/R+Y6Hl 2Q7/DJ2wiT8Z3QfUrsStPJd5rYgYhJ7Y+uxLUjaBu1+g5dz29NpI3Z/Hodk7HqFZ5wsB XkfVQwdYicgb8qKLs3y1Cea2bOqES5ZyxRRxIr36Tzf3fyYVuzkMP2l5KuMx3oDo0Nzh woxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5USZdofT3b7rr0YzPxgVn0M8YXPxXCyJIOd7HvwaYnU=; b=COh8WGVsp28fVVKyBX+//tPEj7+AGsklwJSIO6njJsPnGaWzJTqMODyTrwyfAgMoJl oh+9WiKY3PuRKo9OA6dIJfQsUaECaO+bpjdhCOXy3jWGjpCbpgNJkRuer3iNvtzQ+WX+ S/RdOtyhCybpRq2RAjWaDSamQZPLANHQQUBKzcZgADyCR7i8SY+uu8hWgIDKplFTRbJW bK/sf6dvHkyLxpQSF0RwdrKey85dsSA+P5E99MGnjiJRsOPKYlu59mPG4mJ/JLnIbumv fejqnu1HwvANRlZu39nE7qhiYUfP79Id/Qq3KMlrgNQqxoQJokjkA8mTpMB2lYAdQaAc WfXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DIvKKCkV; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n188-20020a6327c5000000b0042aff6de2d3si278146pgn.179.2022.09.09.04.13.55; Fri, 09 Sep 2022 04:14:09 -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=@redhat.com header.s=mimecast20190719 header.b=DIvKKCkV; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230159AbiIIKpc (ORCPT + 99 others); Fri, 9 Sep 2022 06:45:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230506AbiIIKpR (ORCPT ); Fri, 9 Sep 2022 06:45:17 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DECA84BD20 for ; Fri, 9 Sep 2022 03:45:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662720313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5USZdofT3b7rr0YzPxgVn0M8YXPxXCyJIOd7HvwaYnU=; b=DIvKKCkVgZQENwD9gBdz0yqj5onrtKy7DKDSu3SD47WKdfuZoEfcQ0zNj3oJbt+51hPsyD AsMgv3v/qQUYahCMnhS/iKlSAUlA8VG8poQOLhFTGDrzFqHEOcQaaYejHgrnLjuqrhCIf4 ufhQFLoNB8s+PZxAe4DlQEEAxdhEp7Q= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-537-3yjYgqGqN4ePcQJ31JTu2w-1; Fri, 09 Sep 2022 06:45:10 -0400 X-MC-Unique: 3yjYgqGqN4ePcQJ31JTu2w-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A3A09811E81; Fri, 9 Sep 2022 10:45:09 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4111F40D282E; Fri, 9 Sep 2022 10:45:09 +0000 (UTC) From: Emanuele Giuseppe Esposito To: kvm@vger.kernel.org Cc: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , David Hildenbrand , Maxim Levitsky , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, Emanuele Giuseppe Esposito Subject: [RFC PATCH 1/9] kvm_main.c: move slot check in kvm_set_memory_region Date: Fri, 9 Sep 2022 06:44:58 -0400 Message-Id: <20220909104506.738478-2-eesposit@redhat.com> In-Reply-To: <20220909104506.738478-1-eesposit@redhat.com> References: <20220909104506.738478-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 And make kvm_set_memory_region static, since it is not used outside kvm_main.c Signed-off-by: Emanuele Giuseppe Esposito --- include/linux/kvm_host.h | 2 -- virt/kvm/kvm_main.c | 11 +++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 3b40f8d68fbb..1c5b7b2e35dd 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1108,8 +1108,6 @@ enum kvm_mr_change { KVM_MR_FLAGS_ONLY, }; -int kvm_set_memory_region(struct kvm *kvm, - const struct kvm_userspace_memory_region *mem); int __kvm_set_memory_region(struct kvm *kvm, const struct kvm_userspace_memory_region *mem); void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot); diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index da263c370d00..339de0ed4557 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2007,24 +2007,23 @@ int __kvm_set_memory_region(struct kvm *kvm, } EXPORT_SYMBOL_GPL(__kvm_set_memory_region); -int kvm_set_memory_region(struct kvm *kvm, - const struct kvm_userspace_memory_region *mem) +static int kvm_set_memory_region(struct kvm *kvm, + const struct kvm_userspace_memory_region *mem) { int r; + if ((u16)mem->slot >= KVM_USER_MEM_SLOTS) + return -EINVAL; + mutex_lock(&kvm->slots_lock); r = __kvm_set_memory_region(kvm, mem); mutex_unlock(&kvm->slots_lock); return r; } -EXPORT_SYMBOL_GPL(kvm_set_memory_region); static int kvm_vm_ioctl_set_memory_region(struct kvm *kvm, struct kvm_userspace_memory_region *mem) { - if ((u16)mem->slot >= KVM_USER_MEM_SLOTS) - return -EINVAL; - return kvm_set_memory_region(kvm, mem); } -- 2.31.1