From nobody Thu May 16 06:59:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1709295206; cv=none; d=zohomail.com; s=zohoarc; b=MDSwRP9z6fgAR3lvik6AMDPYFfpNgP9Jhy37SzwOag7mnV0+kw7O04R1sCHdKcUoxdvw9HN7dVLZPKAVErOQiNdNkjrQJmBPrEBPnMM19tNYZt/rbLxzerEj/DHgKClNpabCy/kYLJuwR6k/MRedkOEShNPNczgkEOGME7h91F4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709295206; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bCG8qbxo0n9jYqxMu9sKHaRmzAkZKyYUQZHqWoBMWN4=; b=YpbEx2nYSMmmRB7CZfeecFAoi2Kn6nDEXZJzZ5XgX4JNdpctJOXB4iDUvYAIsPZp5uKDVpNH7rlArd/chBmxJamh13XnTfxT7XWkORMxMrXBdWaiyX02W1Jlj1JofCOyb5V0qUsDDtOAM2H7R54jASvbNHHWB0XtyFNbh0jmWug= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17092952068021015.0496511085719; Fri, 1 Mar 2024 04:13:26 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.687638.1071340 (Exim 4.92) (envelope-from ) id 1rg1lH-0005rr-CT; Fri, 01 Mar 2024 12:13:11 +0000 Received: by outflank-mailman (output) from mailman id 687638.1071340; Fri, 01 Mar 2024 12:13:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rg1lH-0005rk-9p; Fri, 01 Mar 2024 12:13:11 +0000 Received: by outflank-mailman (input) for mailman id 687638; Fri, 01 Mar 2024 12:13:10 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rg1lG-0005rc-7z for xen-devel@lists.xenproject.org; Fri, 01 Mar 2024 12:13:10 +0000 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [2a00:1450:4864:20::535]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1136c420-d7c5-11ee-afd8-a90da7624cb6; Fri, 01 Mar 2024 13:13:09 +0100 (CET) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-566e869f631so251541a12.0 for ; Fri, 01 Mar 2024 04:13:09 -0800 (PST) Received: from andrewcoop.citrite.net (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id s23-20020a170906a19700b00a44899a44ddsm576876ejy.11.2024.03.01.04.13.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 04:13:06 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1136c420-d7c5-11ee-afd8-a90da7624cb6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1709295187; x=1709899987; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bCG8qbxo0n9jYqxMu9sKHaRmzAkZKyYUQZHqWoBMWN4=; b=tRMJ7u6g1d3YRUY2y20bfn5l4D8/AD+Fq1VTYfrAPbRyeX5OfDoFW/VWgR533SCIQ6 tam4B6z5uijA8ZeqXur/GGb6jmkEEMgxZQ1p+jF7UOqVliBS4YoNUhAkM1gBiFxpdm0u M7CIHbxXqfSYUNnZg1ZcnIRPZ8qbFTOIhFPfQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709295187; x=1709899987; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bCG8qbxo0n9jYqxMu9sKHaRmzAkZKyYUQZHqWoBMWN4=; b=he5nvk0uVRjngyZS9tpYW3jd0TszS80z2SGwrCcmbqaeXe4xoC1Ggth/lBofiCM/GD jbt0p7OcvMzmBHcysbUZnTTbeYHvtY7/sIu8MhhrvETe6QiXL6r6a9UMBkgOR090JS01 6E6HN7ty8hNZSWHod+khhDYAIEQlOS7TPFwW3NaZ3duFa9YebiGRHDVlPBWKKA/NZABq eOA2HAwtyUnqscQs6+eT357UsDGSkQ0CvXE8xO9Myjw2B2S8nCbEW9o7mTSFYTrIDz4b lMQG0bl1SgHStCNENYGHQV7SgkeCGrrSMvxkMMx85hb8/C38qvVaOlS//HK/Q5xrVpTh au5w== X-Gm-Message-State: AOJu0YxhSDbAESjTkjlpACKbfLd1JvB18aYDYPVLWUELcY+2GPhAYW73 Tn8huE6MhoHavaKaiDHWtKtPXBlI0G0DKnc3Nwel1WSWVFYlOqSbiBtu0zfz+c+ywwsO2Ol5Xxc L X-Google-Smtp-Source: AGHT+IFd3YQWAm7qoo5X1tJlATEebI+ePrJbrqQHhZWfvEg/6/kEVDSXa+AcdX+MxZjW1Ba8X1OPyw== X-Received: by 2002:a17:906:7d6:b0:a43:88c0:7729 with SMTP id m22-20020a17090607d600b00a4388c07729mr1193092ejc.56.1709295187311; Fri, 01 Mar 2024 04:13:07 -0800 (PST) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Jan Beulich , Wei Liu Subject: [PATCH v2] tests/resource: Fix HVM guest in !SHADOW builds Date: Fri, 1 Mar 2024 12:13:04 +0000 Message-Id: <20240301121304.2661077-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1709295207381100001 Right now, test-resource always creates HVM Shadow guests. But if Xen has SHADOW compiled out, running the test yields: $./test-resource XENMEM_acquire_resource tests Test x86 PV Created d1 Test grant table Test x86 PVH Skip: 95 - Operation not supported and doesn't really test HVM guests, but doesn't fail either. There's nothing paging-mode-specific about this test, so default to HAP if possible and provide a more specific message if neither HAP or Shadow are available. As we've got physinfo to hand, also provide more specific message about the absence of PV or HVM support. Signed-off-by: Andrew Cooper Acked-by: Roger Pau Monn=C3=A9 --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu v2: * Also check XEN_SYSCTL_PHYSCAP_{hvm,pv} --- tools/tests/resource/test-resource.c | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tools/tests/resource/test-resource.c b/tools/tests/resource/te= st-resource.c index 7ae88ea34807..1b10be16a6b4 100644 --- a/tools/tests/resource/test-resource.c +++ b/tools/tests/resource/test-resource.c @@ -20,6 +20,8 @@ static xc_interface *xch; static xenforeignmemory_handle *fh; static xengnttab_handle *gh; =20 +static xc_physinfo_t physinfo; + static void test_gnttab(uint32_t domid, unsigned int nr_frames, unsigned long gfn) { @@ -172,6 +174,37 @@ static void test_domain_configurations(void) =20 printf("Test %s\n", t->name); =20 +#if defined(__x86_64__) || defined(__i386__) + if ( t->create.flags & XEN_DOMCTL_CDF_hvm ) + { + if ( !(physinfo.capabilities & XEN_SYSCTL_PHYSCAP_hvm) ) + { + printf(" Skip: HVM not available\n"); + continue; + } + + /* + * On x86, use HAP guests if possible, but skip if neither HAP= nor + * SHADOW is available. + */ + if ( physinfo.capabilities & XEN_SYSCTL_PHYSCAP_hap ) + t->create.flags |=3D XEN_DOMCTL_CDF_hap; + else if ( !(physinfo.capabilities & XEN_SYSCTL_PHYSCAP_shadow)= ) + { + printf(" Skip: Neither HAP or SHADOW available\n"); + continue; + } + } + else + { + if ( !(physinfo.capabilities & XEN_SYSCTL_PHYSCAP_pv) ) + { + printf(" Skip: PV not available\n"); + continue; + } + } +#endif + rc =3D xc_domain_create(xch, &domid, &t->create); if ( rc ) { @@ -214,6 +247,8 @@ static void test_domain_configurations(void) =20 int main(int argc, char **argv) { + int rc; + printf("XENMEM_acquire_resource tests\n"); =20 xch =3D xc_interface_open(NULL, NULL, 0); @@ -227,6 +262,10 @@ int main(int argc, char **argv) if ( !gh ) err(1, "xengnttab_open"); =20 + rc =3D xc_physinfo(xch, &physinfo); + if ( rc ) + err(1, "Failed to obtain physinfo"); + test_domain_configurations(); =20 return !!nr_failures; --=20 2.30.2