From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9BFDC43603 for ; Thu, 19 Dec 2019 19:28:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9B62224676 for ; Thu, 19 Dec 2019 19:28:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PFHb9ppA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727198AbfLST2x (ORCPT ); Thu, 19 Dec 2019 14:28:53 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:42330 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727191AbfLST2w (ORCPT ); Thu, 19 Dec 2019 14:28:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576783731; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vAIxDhFZG4KNnWbcoM1z/eNh1hoZhidyKE5sG/UkD5w=; b=PFHb9ppAZSdrztzN13AkJXfJwoQ4HSUioSSeXLQYd1I6WwVi74SRjdBcWFfaprsyLpqZrx 7fHiuZ1lBmwi7PBidNlFEv6Bg2/gXdNBvK2u2D5YtknNCz41xYPos9aReo8fAXZ7lU1BHL nSiqfJu8QSBS3SnXFsyFIlfUDzdDets= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-22-7KuzwdpAO0uhdJbA8J3gpA-1; Thu, 19 Dec 2019 14:28:48 -0500 X-MC-Unique: 7KuzwdpAO0uhdJbA8J3gpA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3B2CA18FF698; Thu, 19 Dec 2019 19:28:45 +0000 (UTC) Received: from gondolin (ovpn-117-134.ams2.redhat.com [10.36.117.134]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01C375DA70; Thu, 19 Dec 2019 19:28:37 +0000 (UTC) Date: Thu, 19 Dec 2019 20:28:35 +0100 From: Cornelia Huck To: Sean Christopherson Cc: Marc Zyngier , James Hogan , Paul Mackerras , Christian Borntraeger , Janosch Frank , Paolo Bonzini , James Morse , Julien Thierry , Suzuki K Poulose , David Hildenbrand , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kurz Subject: Re: [PATCH v2 24/45] KVM: Add kvm_arch_vcpu_precreate() to handle pre-allocation issues Message-ID: <20191219202835.06fc6f2f.cohuck@redhat.com> In-Reply-To: <20191218215530.2280-25-sean.j.christopherson@intel.com> References: <20191218215530.2280-1-sean.j.christopherson@intel.com> <20191218215530.2280-25-sean.j.christopherson@intel.com> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org On Wed, 18 Dec 2019 13:55:09 -0800 Sean Christopherson wrote: > Add a pre-allocation arch hook to handle checks that are currently done > by arch specific code prior to allocating the vCPU object. This paves > the way for moving the allocation to common KVM code. > > Acked-by: Christoffer Dall > Signed-off-by: Sean Christopherson > --- > arch/mips/kvm/mips.c | 5 +++++ > arch/powerpc/kvm/powerpc.c | 5 +++++ > arch/s390/kvm/kvm-s390.c | 12 ++++++++---- > arch/x86/kvm/x86.c | 14 +++++++++----- > include/linux/kvm_host.h | 1 + > virt/kvm/arm/arm.c | 21 +++++++++++---------- > virt/kvm/kvm_main.c | 4 ++++ > 7 files changed, 43 insertions(+), 19 deletions(-) > (...) > diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c > index d9e6bf3d54f0..57c6838dff37 100644 > --- a/arch/s390/kvm/kvm-s390.c > +++ b/arch/s390/kvm/kvm-s390.c > @@ -3035,15 +3035,19 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) > return rc; > } > > +int kvm_arch_vcpu_precreate(struct kvm *kvm, unsigned int id) > +{ > + if (!kvm_is_ucontrol(kvm) && !sca_can_add_vcpu(kvm, id)) > + return -EINVAL; > + return 0; > +} > + > struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, > unsigned int id) > { > struct kvm_vcpu *vcpu; > struct sie_page *sie_page; > - int rc = -EINVAL; > - > - if (!kvm_is_ucontrol(kvm) && !sca_can_add_vcpu(kvm, id)) > - goto out; > + int rc; You might want to make this int rc = -ENOMEM; instead. > > rc = -ENOMEM; > (...) Regardless, Reviewed-by: Cornelia Huck