Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp154983pxt; Wed, 4 Aug 2021 08:03:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytEdrZj6ecfTe9aqi//g9ANq/UYqZTWa905Cku+U7JO5DI3Bh5muXz/f2Rc0Ab6EJ8LRBV X-Received: by 2002:a5e:c803:: with SMTP id y3mr352018iol.107.1628089394746; Wed, 04 Aug 2021 08:03:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628089394; cv=none; d=google.com; s=arc-20160816; b=tr9kKx8BTXmi1qoxcV5B8olPDJeiBRYOnulOsCcdn1iQ2PkazK10m+n1EIKqQxw4xY jR8u6X9aX48VTB87re4c0FOsqZJJr3YE2in3htOtKPCI9GnfLPGnGLrVoxQ4CsXTLc9Y 2AgXtRGGP5djwPp9Ca8XJvQtzZMy44trwMuTimK+RGyTm6RNHHX5sxgx2Lk7dBMycoR7 03eLE5ww79Kx/zHyKWCs/nhBc59PjOz3pA7bSz2GuASH/HzrS1nqBuvnO0gbxhTI+9fA y4KYVnrk343e/Nh5Vki2dWOLqM9YTgIyYaLqqMieJvEp47XPYayB0Aeag/STDm5QQK9z o07w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=+8zaG8kUEPUeqQYyLMdsGj4K9pQIoJbdASe/poY1g8c=; b=n3FCEAFefV+XIsskWXuP9NDtYz/5gqDXEfANWhuVOZ/uPOW/ENQKzaEg9KD39jshyn rutiMt2RZ3rFUqmjdROimmCo3SOvM7mRWV8nQt1VxQSDvEwRBiCzcWzwIVI0FiBQzVQT 9hepy1y/OwEstttEWfhJRqL9bWWt9Yby7PhMmdaRvLyirJaEiaRIveD6wvIriuAgVNPV Dex5kWi4ConyMo+cOYb2ORmV2O9bcJ9wPsYX7W7m22NrNXt5rRydY3O35toG5hfy2+F2 vjQillJVd8xzYRqYUFTK6yWYnpRyCSRgMT26ABc4ri0A3KpuUhRSZzePcPK9vWc0cA5C rjvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id y11si2993366ilu.1.2021.08.04.08.03.01; Wed, 04 Aug 2021 08:03:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S238215AbhHDOmo (ORCPT + 99 others); Wed, 4 Aug 2021 10:42:44 -0400 Received: from mga05.intel.com ([192.55.52.43]:48481 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238191AbhHDOmm (ORCPT ); Wed, 4 Aug 2021 10:42:42 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10065"; a="299522001" X-IronPort-AV: E=Sophos;i="5.84,294,1620716400"; d="scan'208";a="299522001" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2021 07:42:29 -0700 X-IronPort-AV: E=Sophos;i="5.84,294,1620716400"; d="scan'208";a="511998985" Received: from xiaoyaol-mobl.ccr.corp.intel.com (HELO [10.255.28.78]) ([10.255.28.78]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2021 07:42:23 -0700 Subject: Re: [RFC PATCH 1/4] KVM: selftests: Add support for creating non-default type VMs To: Maxim Levitsky , Erdem Aktas , linux-kselftest@vger.kernel.org Cc: Sean Christopherson , Peter Gonda , Marc Orr , Sagi Shahar , Paolo Bonzini , Shuah Khan , Andrew Jones , Ben Gardon , Peter Xu , David Matlack , Emanuele Giuseppe Esposito , Christian Borntraeger , Ricardo Koller , Eric Auger , Yanan Wang , Aaron Lewis , Jim Mattson , Oliver Upton , Vitaly Kuznetsov , Peter Shier , Axel Rasmussen , Zhenzhong Duan , "Maciej S. Szmigiero" , Like Xu , open list , "open list:KERNEL VIRTUAL MACHINE (KVM)" References: <20210726183816.1343022-1-erdemaktas@google.com> <20210726183816.1343022-2-erdemaktas@google.com> From: Xiaoyao Li Message-ID: <42a812a9-7f17-2a26-d289-1f921408a469@intel.com> Date: Wed, 4 Aug 2021 22:42:21 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/4/2021 10:24 PM, Maxim Levitsky wrote: > On Wed, 2021-08-04 at 14:09 +0800, Xiaoyao Li wrote: >> On 7/27/2021 2:37 AM, Erdem Aktas wrote: >>> Currently vm_create function only creates KVM_X86_LEGACY_VM type VMs. >>> Changing the vm_create function to accept type parameter to create >>> new VM types. >>> >>> Signed-off-by: Erdem Aktas >>> Reviewed-by: Sean Christopherson >>> Reviewed-by: Peter Gonda >>> Reviewed-by: Marc Orr >>> Reviewed-by: Sagi Shahar >>> --- >>> .../testing/selftests/kvm/include/kvm_util.h | 1 + >>> tools/testing/selftests/kvm/lib/kvm_util.c | 29 +++++++++++++++++-- >>> 2 files changed, 27 insertions(+), 3 deletions(-) >>> >>> diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h >>> index d53bfadd2..c63df42d6 100644 >>> --- a/tools/testing/selftests/kvm/include/kvm_util.h >>> +++ b/tools/testing/selftests/kvm/include/kvm_util.h >>> @@ -88,6 +88,7 @@ int vcpu_enable_cap(struct kvm_vm *vm, uint32_t vcpu_id, >>> void vm_enable_dirty_ring(struct kvm_vm *vm, uint32_t ring_size); >>> >>> struct kvm_vm *vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm); >>> +struct kvm_vm *__vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm, int type); >>> void kvm_vm_free(struct kvm_vm *vmp); >>> void kvm_vm_restart(struct kvm_vm *vmp, int perm); >>> void kvm_vm_release(struct kvm_vm *vmp); >>> diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c >>> index e5fbf16f7..70caa3882 100644 >>> --- a/tools/testing/selftests/kvm/lib/kvm_util.c >>> +++ b/tools/testing/selftests/kvm/lib/kvm_util.c >>> @@ -180,13 +180,36 @@ _Static_assert(sizeof(vm_guest_mode_params)/sizeof(struct vm_guest_mode_params) >>> * Return: >>> * Pointer to opaque structure that describes the created VM. >>> * >>> - * Creates a VM with the mode specified by mode (e.g. VM_MODE_P52V48_4K). >>> + * Wrapper VM Create function to create a VM with default type (0). >> >> Can we pass KVM_X86_LEGACY_VM (whatever name when it's upstreamed) >> instead of 0? > > To be honest I would prefer this to be called something like KVM_X86_STANDARD_VM, > or something. > > I don't think that normal unencrypted virtualization is already legacy, even if TDX > docs claim that. I'm not proposing to use this specific name introduced in TDX RFC series, but proposing to use the name defined in KVM in the future instead of hard-coded 0. Yes, KVM_X86_STANDARD_VM or KVM_X86_NORMAL_VM (proposed by Paolo) is better than KVM_X86_LEGACY_VM. > Just my personal opinion. > > Best regards, > Maxim Levitsky > >> >>> + */ >>> +struct kvm_vm *vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm) >>> +{ >>> + return __vm_create(mode, phy_pages, perm, 0); >>> +} >>> + >> >> > >