Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4950246ybg; Mon, 21 Oct 2019 17:40:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwe1k99RxMF3QLn4j1q79w5hzDW8rcz3zztcb/sSY+ioaTIW7TFntxwHPqRk/Vv2DIpVdTY X-Received: by 2002:a17:906:a884:: with SMTP id ha4mr13518008ejb.192.1571704825815; Mon, 21 Oct 2019 17:40:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571704825; cv=none; d=google.com; s=arc-20160816; b=wpJMLPL6J1QECwPDWxLFpkb/3j55TFXQ9Fk5YXpJm18edkvoYBqmwJgks9CfF3nv5a xV1v+m42RrqtPIyK0tH1v0V3zE78wyPat0L4VbwPhys17Vy7FcFC2u1FRujDzpSDyAuc 4zo2Xilw2U1nI0D/M97rSEiRB7XH99fep0pmklT+0yTIjjMc3dtub3tt876C4ah7Zmp/ OPtQyW9qddl9zBwRM/psaw3awDM0ZRhxiY322F7JuV/Mb8LjMTbsEnE+jVczMYxWUs7t DgErItTcq3A8E9LwXTcX3KluWNJKxosyl001T00D7gU33Kq3E8AgilepabnB+g8Mo5Yk K7Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Nhi32uToVhT/iDgIRmDCX0nkaJfDtHoEFSzPmLhXO1g=; b=MXHnJAzZpOb3rekzviSm6sGf2VdUhQO+bc1zBSWpX4Sg3ij/H5R+SdsYUNkWn2VoJr L3V9/m6Oh/5fd3/TRjz3GLIuy6rN7c4H3Y3NYQh4Bid4SdUSQxj0bLAqoycGBYLFzugO cfBUJrUFkSIGl16Vnh7NsNWFsZy7XoTY+biifwWf7yRcuG2ENuwR4TNr3xTFuABOAXek 8XQh4RjE8HO8EhnyEdOE62W9bo1znoxn0iXqM3716l9lXzmBqsiPSoUGpzk/bsqiFMYW cJlC/2wmZUu45+mHVlqFCMJT5lvlPc9OJqo4w2+fgoepc0kbESmreYxYXzt+HE/tZP3f pAug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y47si11188915edd.236.2019.10.21.17.40.02; Mon, 21 Oct 2019 17:40:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730980AbfJVAg6 (ORCPT + 99 others); Mon, 21 Oct 2019 20:36:58 -0400 Received: from mga07.intel.com ([134.134.136.100]:35282 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730577AbfJVAfl (ORCPT ); Mon, 21 Oct 2019 20:35:41 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Oct 2019 17:35:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,325,1566889200"; d="scan'208";a="348897207" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.41]) by orsmga004.jf.intel.com with ESMTP; 21 Oct 2019 17:35:39 -0700 From: Sean Christopherson To: James Hogan , Paul Mackerras , Christian Borntraeger , Janosch Frank , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Marc Zyngier Cc: David Hildenbrand , Cornelia Huck , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , James Morse , Julien Thierry , Suzuki K Poulose , linux-mips@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Subject: [PATCH v2 04/15] KVM: x86: Allocate memslot resources during prepare_memory_region() Date: Mon, 21 Oct 2019 17:35:26 -0700 Message-Id: <20191022003537.13013-5-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20191022003537.13013-1-sean.j.christopherson@intel.com> References: <20191022003537.13013-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allocate the various metadata structures associated with a memslot during during kvm_arch_prepare_memory_region(), which paves the way for removing kvm_arch_create_memslot() altogether. Moving x86's memory allocation only changes the order of kernel memory allocations between x86 and common KVM code. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index f26f8be4e621..fa80f07ba501 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -9601,6 +9601,12 @@ void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free, int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot, unsigned long npages) +{ + return 0; +} + +static int kvm_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot, + unsigned long npages) { int i; @@ -9678,6 +9684,9 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, const struct kvm_userspace_memory_region *mem, enum kvm_mr_change change) { + if (change == KVM_MR_CREATE) + return kvm_create_memslot(kvm, memslot, + mem->memory_size >> PAGE_SHIFT); return 0; } -- 2.22.0