From patchwork Wed Feb 8 14:01:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 54441 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3475438wrn; Wed, 8 Feb 2023 06:09:00 -0800 (PST) X-Google-Smtp-Source: AK7set+BP0bVp2N6Ljx0G6nl30FrOQSvIA2m3lHIcu3DVGaVxzLvCp4ZA+6IeSPK9mpqEOpIcJac X-Received: by 2002:a17:906:5185:b0:8ae:ea08:3842 with SMTP id y5-20020a170906518500b008aeea083842mr1201456ejk.7.1675865340667; Wed, 08 Feb 2023 06:09:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675865340; cv=none; d=google.com; s=arc-20160816; b=PQjQucP8wdrwEyknJ7r825PL0hAMoOcA7IFSvSCtxcdYyQDai3olm6AMIGMskIKPzQ iGZHrLYxxLZ85Imfs6cRsEGjGY9ASlClGV5Y/7FsgVI6FSgKp5vTcGH2SWJndH4IS1vu 4deabPVBP6YH4bto15PEyeyypoLYIuYulb4i5CU2DFEy8SfIQaqy3GN/NRK7Wow+X23g juYkNz3X+yvPx4Xxa0tNxj/tbJxr/MALyKluLX1O5gkMZyIFGosM/qHLPU+gQgmQ2ilx /INzlpKZIZ4EjU6YuRRzzr5XhE23cqCuJap9DBPNjFU5oBPfOxSTwxkP4K+otbUiFMtW ImIA== 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=LLoh5TBX9JIZXNzcUIXGAY+PkQJYUmsvSDRrT4/hutQ=; b=0+jqrSMZB2FmuAmV4NybyVFeXF/hE3zuwTgL/rCNDyvMXk93YpyMUvhrtVfgHYOOIN E25/xszSNs9fB9RDRdhkmUso3VaoLzZYx0sgj9wn6aUD0hnfF40eI8mPnDk3mA2x/gQT GP8z5s+LP5QtPzBmBNgI05v51Djatf838KSXj3nOjsV9seGKEkdvk63Dt4WgNpNT3AM9 PgBcP7m3GMiAHVN5+xqHXSarqViWAjSniCTL3QSLVqys0B5v/zNnYtohLGuuPpbYypE7 iVoRMg6UZirhEHCobIcH3+sD+thf29mrhnKz9VxaCxYAGglATdMRMiLm0heLj3p8gpfX 99Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="NxHCjo0/"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eq23-20020a170907291700b008976e610574si14118793ejc.114.2023.02.08.06.08.34; Wed, 08 Feb 2023 06:09:00 -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=@redhat.com header.s=mimecast20190719 header.b="NxHCjo0/"; 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 S231202AbjBHODD (ORCPT + 99 others); Wed, 8 Feb 2023 09:03:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230365AbjBHODB (ORCPT ); Wed, 8 Feb 2023 09:03:01 -0500 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 1AB6630E80 for ; Wed, 8 Feb 2023 06:01:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675864898; 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=LLoh5TBX9JIZXNzcUIXGAY+PkQJYUmsvSDRrT4/hutQ=; b=NxHCjo0/8389IM6XPTMRPbCuMUgjdvVjHSbnS1B2ZFrpzq7DcaF2ZRZHiBhYDj1GjByLBe 7/lDLJ8XmW5HS4d0Jt6I1weJyUAETb4CH68MLDJZmPva6PCl8RKkZqZeqFV79Ccjeqdsxi I3xt3VXtWmjdvc2kjYzXZTMa6OphZjU= 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-665-MhELPkxDNaajK6CI6PJt4A-1; Wed, 08 Feb 2023 09:01:34 -0500 X-MC-Unique: MhELPkxDNaajK6CI6PJt4A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B55318057A6; Wed, 8 Feb 2023 14:01:30 +0000 (UTC) Received: from thuth.com (unknown [10.39.193.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F86C1415113; Wed, 8 Feb 2023 14:01:27 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson Cc: kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kvm-riscv@lists.infradead.org, Marc Zyngier , James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Christian Borntraeger , Janosch Frank , David Hildenbrand , Gavin Shan , Steven Price , Cornelia Huck Subject: [PATCH v2 3/6] KVM: x86: Remove the KVM_GET_NR_MMU_PAGES ioctl Date: Wed, 8 Feb 2023 15:01:02 +0100 Message-Id: <20230208140105.655814-4-thuth@redhat.com> In-Reply-To: <20230208140105.655814-1-thuth@redhat.com> References: <20230208140105.655814-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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?1757272175346046453?= X-GMAIL-MSGID: =?utf-8?q?1757272175346046453?= The KVM_GET_NR_MMU_PAGES ioctl is quite questionable on 64-bit hosts since it fails to return the full 64 bits of the value that can be set with the corresponding KVM_SET_NR_MMU_PAGES call. Its "long" return value is truncated into an "int" in the kvm_arch_vm_ioctl() function. Since this ioctl also never has been used by userspace applications (QEMU, Google's internal VMM, kvmtool and CrosVM have been checked), it's likely the best if we remove this badly designed ioctl before anybody really tries to use it. Signed-off-by: Thomas Huth Reviewed-by: Sean Christopherson --- arch/x86/kvm/x86.c | 8 -------- include/uapi/linux/kvm.h | 2 +- tools/include/uapi/linux/kvm.h | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index da4bbd043a7b..2d210ab47e21 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6007,11 +6007,6 @@ static int kvm_vm_ioctl_set_nr_mmu_pages(struct kvm *kvm, return 0; } -static unsigned long kvm_vm_ioctl_get_nr_mmu_pages(struct kvm *kvm) -{ - return kvm->arch.n_max_mmu_pages; -} - static int kvm_vm_ioctl_get_irqchip(struct kvm *kvm, struct kvm_irqchip *chip) { struct kvm_pic *pic = kvm->arch.vpic; @@ -6689,9 +6684,6 @@ long kvm_arch_vm_ioctl(struct file *filp, case KVM_SET_NR_MMU_PAGES: r = kvm_vm_ioctl_set_nr_mmu_pages(kvm, arg); break; - case KVM_GET_NR_MMU_PAGES: - r = kvm_vm_ioctl_get_nr_mmu_pages(kvm); - break; case KVM_CREATE_IRQCHIP: { mutex_lock(&kvm->lock); diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 55155e262646..59dc7e5d4974 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -1442,7 +1442,7 @@ struct kvm_vfio_spapr_tce { #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) #define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44) -#define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) +#define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) /* deprecated */ #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \ struct kvm_userspace_memory_region) #define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47) diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h index 55155e262646..59dc7e5d4974 100644 --- a/tools/include/uapi/linux/kvm.h +++ b/tools/include/uapi/linux/kvm.h @@ -1442,7 +1442,7 @@ struct kvm_vfio_spapr_tce { #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) #define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44) -#define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) +#define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) /* deprecated */ #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \ struct kvm_userspace_memory_region) #define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47)