From patchwork Mon Dec 26 12:03:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 13081790 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDB38C46467 for ; Mon, 26 Dec 2022 12:03:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231997AbiLZMDg (ORCPT ); Mon, 26 Dec 2022 07:03:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229533AbiLZMDb (ORCPT ); Mon, 26 Dec 2022 07:03:31 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E76896302 for ; Mon, 26 Dec 2022 04:03:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=T09LeAy9NPz3ILbZmugbi6Et0fBLJJYdlvloVwBwbyQ=; b=GzfL7Tax7m0tUQ9fBD5sfN8KQN trFKKC97Z/nqo7yCK9L/DA9nDxpztOGO8/veeTIV6qx1L37Kj5Yx7LBWmxmAIIjL0jjcGLgurSCRR 1hIWkyyPXQpfS7X/zILA+KT4fgrQVczUKVo41q9J2I2FwxD80U3O7faha3jGqIbZfbWmkCrwWjh9G hgl4Yor1yZY0+MH2uScBGlkUb9bGv6aD7hnEMmgt50iJj5aeMWNK2AIhdNkEjwhn3U7ddkyS4cNQa d7v3cDhOG1IOUCzKkXarXDH/4cLNh9XemvZmvbQ/FnWd9M3mfGTHEv6eg5+65KMzPTTccFRSfuMLt EfYGVH6w==; Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1p9mCZ-006e9r-PQ; Mon, 26 Dec 2022 12:03:31 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1p9mCO-004ilu-QB; Mon, 26 Dec 2022 12:03:20 +0000 From: David Woodhouse To: Paolo Bonzini Cc: Michal Luczaj , Sean Christopherson , Yu Zhang , kvm@vger.kernel.org, Paul Durrant Subject: [PATCH 4/6] KVM: x86/xen: Simplify eventfd IOCTLs Date: Mon, 26 Dec 2022 12:03:18 +0000 Message-Id: <20221226120320.1125390-4-dwmw2@infradead.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221226120320.1125390-1-dwmw2@infradead.org> References: <20221226120320.1125390-1-dwmw2@infradead.org> MIME-Version: 1.0 Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Michal Luczaj Port number is validated in kvm_xen_setattr_evtchn(). Remove superfluous checks in kvm_xen_eventfd_assign() and kvm_xen_eventfd_update(). Signed-off-by: Michal Luczaj Message-Id: <20221222203021.1944101-3-mhal@rbox.co> Signed-off-by: Paolo Bonzini Signed-off-by: David Woodhouse --- arch/x86/kvm/xen.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c index 9b75457120f7..bddbe5ac5cfa 100644 --- a/arch/x86/kvm/xen.c +++ b/arch/x86/kvm/xen.c @@ -1810,9 +1810,6 @@ static int kvm_xen_eventfd_update(struct kvm *kvm, struct evtchnfd *evtchnfd; int ret; - if (!port || port >= max_evtchn_port(kvm)) - return -EINVAL; - /* Protect writes to evtchnfd as well as the idr lookup. */ mutex_lock(&kvm->lock); evtchnfd = idr_find(&kvm->arch.xen.evtchn_ports, port); @@ -1858,12 +1855,9 @@ static int kvm_xen_eventfd_assign(struct kvm *kvm, { u32 port = data->u.evtchn.send_port; struct eventfd_ctx *eventfd = NULL; - struct evtchnfd *evtchnfd = NULL; + struct evtchnfd *evtchnfd; int ret = -EINVAL; - if (!port || port >= max_evtchn_port(kvm)) - return -EINVAL; - evtchnfd = kzalloc(sizeof(struct evtchnfd), GFP_KERNEL); if (!evtchnfd) return -ENOMEM;