Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3905694pxv; Mon, 26 Jul 2021 15:27:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxofcWxtuUdCpm37wnXAPMiarNmUjEfj0ACjX+1uC8eOw+4BIjVFGsANXFNGAxmwH7TsF0c X-Received: by 2002:a05:6638:41a7:: with SMTP id az39mr18470163jab.52.1627338448685; Mon, 26 Jul 2021 15:27:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627338448; cv=none; d=google.com; s=arc-20160816; b=WpeIW/eCS+JwafzBpS74d4zl8ReT5KXdEcLLsyk4Ge8VyFQakHcsVjqZZgCWQfM6d+ 4O5jIaOdO51WcMTCCKngojlIttMd1xUWwtLCkPz4BXM3BhJ3qgGEq+trd4M5MhFLk3mF rDmaQwmPbaWQ18s1wlBRv5TDgmQ6cd628oeYpADegrMOSXqx08Cji0vrWyIpdXk9d5W8 nkLyNnmUwabLtT2xSFBt/5U5X69eOLrqdHX3k9pUQBka6ExlwzDaQsn//g4n+ARFBYlM /OsxrVbhUDqxiUWJnf3cCiD/AMHlT1TZzLC4pulVr47Nem6Gr0rU01h53sq1shd03HbB uKQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/+BJHwQCEyZHcaZdbprSZPe+y/dzPxjT0mqjzI4mft8=; b=ppvsW2kiBHFO5mLjIT04Y+BHa1jKAHlrHf5mYAUaSVKF5p/hTF5vgESb/J2xTEp0NP 07Wgth9ljjZrex+slME9eDOI+kdSGIrEkWsqiOBbzhQwUIZ4iaHNPseMm25UBVNljirU eIS/nlgF2GauxcG7QIqrb3y84t9DRbds/baSkuQkuo9fS846nB8+60LhR++8U7ND3IcA dTWK24I+3QTbOEJPAThzdQ40H+aj5yixGr8fTns6GmYHvmukjJNYAuL1EFhkKF5ZaX2v QJiPWuCgeo5+SfwmzBkGBo+Py2iBCghXcpvHJPXYHpZ+C5uJ+Rklo4DguZJZV8uZyzrp bQRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XOJ4As13; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h12si1064336ild.123.2021.07.26.15.27.17; Mon, 26 Jul 2021 15:27:28 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=XOJ4As13; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233643AbhGZVpz (ORCPT + 99 others); Mon, 26 Jul 2021 17:45:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233693AbhGZVpx (ORCPT ); Mon, 26 Jul 2021 17:45:53 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51F1FC061757 for ; Mon, 26 Jul 2021 15:26:21 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id ds11-20020a17090b08cbb0290172f971883bso1156255pjb.1 for ; Mon, 26 Jul 2021 15:26:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=/+BJHwQCEyZHcaZdbprSZPe+y/dzPxjT0mqjzI4mft8=; b=XOJ4As13Ddv1Zv4Si7aLITV2FNguggs9creN7NCAOdJd2JF1ie5suTQ4egOzyTjaIa Hl03gr+MUKSixpTDfESt41Oa3w7ZSO8SE1bBV5CEJDM9XXjwljH1ju+CukWQI2QA+Szp 0QMWPQfGn4fOJmzugVf6Q+dDjuIuqolyhzxS37dqEhZsAYP9qCoX2VTwT3U6bbV8dghG EYr4ojU2daMUKvsrk+/UqV2Pl+kEr97qTAubdYzr2+WOKVxn1hGHlcrAvY53oJi3DKz+ E6qODtV39JkV9ddgkitlEIWvlby+eNxoMft+bxN0OGC7YUwNi9UnWmIn+ZTeLNJK0vuz mq5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/+BJHwQCEyZHcaZdbprSZPe+y/dzPxjT0mqjzI4mft8=; b=rB62hsJh21Pp9c7UTn9y9omUEM3BxPtPT9mRL56MRUS7ncgh915LiXb4TtEO72mktj ACrPzEIIdZXvcfuWItf/PEsX4r1iucpvAv6D9rEb3KrxTSIYoFKWQl641kzTH+C9YGbo U4wQld9G/lkBzeaGNrjN7gRxAD66RPOEMj9XsAJqJyi52hK2L06gpGkVT1Y7JSnbgL9g 2yBBwPQ1a5SvnlnR0THLmJiw15ZcYsE6mHgNZQ2RdenXP8SxtMyqdC7zM7zeFVY+4iAC yCe3uXNGRT9hqyCPbM/HzR4UeK4RQtPkYfHBvIB6tnljDcZDIvV3TJNVG02oAUEmi4/a iqIg== X-Gm-Message-State: AOAM530A+zpDhjbKeOngu4t8QNSlbGgPp/X9FF7x38iWjWxDXdBLoARC lfjrh/52O+W6R8g5LIv6+px4WQ== X-Received: by 2002:aa7:9e5c:0:b029:32b:4e2a:e549 with SMTP id z28-20020aa79e5c0000b029032b4e2ae549mr20136064pfq.68.1627338380586; Mon, 26 Jul 2021 15:26:20 -0700 (PDT) Received: from google.com (254.80.82.34.bc.googleusercontent.com. [34.82.80.254]) by smtp.gmail.com with ESMTPSA id h9sm597057pjk.56.2021.07.26.15.26.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 15:26:19 -0700 (PDT) Date: Mon, 26 Jul 2021 22:26:16 +0000 From: David Matlack To: Erdem Aktas Cc: linux-kselftest@vger.kernel.org, Sean Christopherson , Peter Gonda , Marc Orr , Sagi Shahar , Paolo Bonzini , Shuah Khan , Andrew Jones , Ben Gardon , Peter Xu , 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)" Subject: Re: [RFC PATCH 1/4] KVM: selftests: Add support for creating non-default type VMs Message-ID: References: <20210726183816.1343022-1-erdemaktas@google.com> <20210726183816.1343022-2-erdemaktas@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210726183816.1343022-2-erdemaktas@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 26, 2021 at 11:37:54AM -0700, 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 Reviewed-by: David Matlack (aside from the nit below) > --- > .../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); nit: Consider using a more readable function name such as vm_create_with_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). > + */ > +struct kvm_vm *vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm) > +{ > + return __vm_create(mode, phy_pages, perm, 0); > +} > + > +/* > + * VM Create with a custom type > + * > + * Input Args: > + * mode - VM Mode (e.g. VM_MODE_P52V48_4K) > + * phy_pages - Physical memory pages > + * perm - permission > + * type - VM type > + * > + * Output Args: None > + * > + * 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) and the > + * type specified in type (e.g. KVM_X86_LEGACY_VM, KVM_X86_TDX_VM ...). > * When phy_pages is non-zero, a memory region of phy_pages physical pages > * is created and mapped starting at guest physical address 0. The file > * descriptor to control the created VM is created with the permissions > * given by perm (e.g. O_RDWR). > */ > -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) > { > struct kvm_vm *vm; > > @@ -200,7 +223,7 @@ struct kvm_vm *vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm) > INIT_LIST_HEAD(&vm->userspace_mem_regions); > > vm->mode = mode; > - vm->type = 0; > + vm->type = type; > > vm->pa_bits = vm_guest_mode_params[mode].pa_bits; > vm->va_bits = vm_guest_mode_params[mode].va_bits; > -- > 2.32.0.432.gabb21c7263-goog >