From patchwork Fri Sep 22 15:00:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 143700 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5898860vqi; Fri, 22 Sep 2023 15:21:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3nI2wkMQn5xH4lsYuQZw1ou40F1Cj/+aPo+u5XhbcdDOohHL0Y/L25/xquk0FdD8UgHap X-Received: by 2002:a17:902:d2cf:b0:1c3:aef9:872e with SMTP id n15-20020a170902d2cf00b001c3aef9872emr985890plc.34.1695421306531; Fri, 22 Sep 2023 15:21:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695421306; cv=none; d=google.com; s=arc-20160816; b=qC5xz9/u7n1FiLevdyQTrgA6Szconxk4VtFMojEvJP5qFaKFsci1m5ALeRQdUBMuqZ elxGLvLumNw7KRaZBBHqX1wpVm2LtJvg2MUnmRgN4IZU20bo9nhUEZyqtuIU3C9GJljp j9nZLtrpxgDMsOJFnLBFxdJVPJgt/WbV5WIwspyPhlH7j+gWjeHNoSqCetLKw84hv/7y 0YwnoozneCtzoHwZhWzNw+qpvezlqF63Rr1gxVyVAQFkloTmTU7owg/2ZmNwxcMPcA9g TvNWs7BXo39SI1JjvEaFxRfBzOfOPr+0f6sjMfqKlvbBKMaYKuW1RltsClTHt8v9uzMm hXgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wvF5vbKQ0oqapTek2ihIVp8v4huETUVpmznY/AbmTjg=; fh=NVKswJvclYk1MEC7AfFzo67YIylApYMwZ7eFzXKDgdk=; b=dxwCW+7/TyhuPlOhPBdt9Q2/jQAN/g7PxvvAVycaA5dXjkFp45W2OfF5JoTfdtDe7k Anki/4TESoLF/2MSLAG6OL4ovPdjnMxaynqBf7HsM6pQcmuIkZ08qPi2+mhYHDkJe97+ Xg07pz5gBuipp8gv/NFb3dMP99w17joKRNdrO2djBppsHWcvtlA/Hn/0xNJlheuIkSz3 4ztx83rplVkLK+1HsCMBRlHKwJAXbxuF7CaaahfTwy/CqRRtWQQX/f+w2a6gygiCSnyX dqJVwSQkKc0luGYZXL7qNdu3PLVZ3VCVv2JoaS4EBGRlJsjltZCSuVqgoYvYgONd+GsV MJjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=HUU9PELS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id l11-20020a170903120b00b001b5589848absi4870440plh.234.2023.09.22.15.21.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 15:21:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=HUU9PELS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 06AA8822E577; Fri, 22 Sep 2023 08:02:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232683AbjIVPBH (ORCPT + 29 others); Fri, 22 Sep 2023 11:01:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232326AbjIVPAk (ORCPT ); Fri, 22 Sep 2023 11:00:40 -0400 Received: from mail.xenproject.org (mail.xenproject.org [104.130.215.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9863EC6; Fri, 22 Sep 2023 08:00:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=wvF5vbKQ0oqapTek2ihIVp8v4huETUVpmznY/AbmTjg=; b=HUU9PELSPBkRTUD0OXTp2POR7l F/8W4olaRgQe4T4AYBgIYC+7o/Go6lA7GAEkCvUPJ7Ij4AQAxto9ME+y6CMUOJMOmVhanY9O+XXvU vrQiR2fsqxZlC4Zk7iv+AnD7BfC3jQsgDednOmUpsRXLNUedBupmj7SPf2tF3xuUlPSE=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qjhdx-00045k-AE; Fri, 22 Sep 2023 15:00:33 +0000 Received: from ec2-63-33-11-17.eu-west-1.compute.amazonaws.com ([63.33.11.17] helo=REM-PW02S00X.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qjhdx-0005y2-2o; Fri, 22 Sep 2023 15:00:33 +0000 From: Paul Durrant To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Paul Durrant , Sean Christopherson , Paolo Bonzini , David Woodhouse Subject: [PATCH v5 09/10] KVM: selftests / xen: re-map vcpu_info using HVA rather than GPA Date: Fri, 22 Sep 2023 15:00:08 +0000 Message-Id: <20230922150009.3319-10-paul@xen.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230922150009.3319-1-paul@xen.org> References: <20230922150009.3319-1-paul@xen.org> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 22 Sep 2023 08:02:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777763782424910924 X-GMAIL-MSGID: 1777778091912661097 From: Paul Durrant If the relevant capability (KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA) is present then re-map vcpu_info using the HVA part way through the tests to make sure then there is no functional change. Signed-off-by: Paul Durrant --- Cc: Sean Christopherson Cc: Paolo Bonzini Cc: David Woodhouse v5: - New in this version. --- .../selftests/kvm/x86_64/xen_shinfo_test.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c b/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c index e6672ae1d9de..a5d3aea8fd95 100644 --- a/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c +++ b/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c @@ -66,6 +66,7 @@ enum { TEST_POLL_TIMEOUT, TEST_POLL_MASKED, TEST_POLL_WAKE, + SET_VCPU_INFO, TEST_TIMER_PAST, TEST_LOCKING_SEND_RACE, TEST_LOCKING_POLL_RACE, @@ -325,6 +326,10 @@ static void guest_code(void) GUEST_SYNC(TEST_POLL_WAKE); + /* Set the vcpu_info to point at exactly the place it already is to + * make sure the attribute is functional. */ + GUEST_SYNC(SET_VCPU_INFO); + /* A timer wake an *unmasked* port which should wake us with an * actual interrupt, while we're polling on a different port. */ ports[0]++; @@ -892,6 +897,16 @@ int main(int argc, char *argv[]) alarm(1); break; + case SET_VCPU_INFO: + if (has_shinfo_hva) { + struct kvm_xen_vcpu_attr vih = { + .type = KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO_HVA, + .u.hva = (unsigned long)vinfo + }; + vcpu_ioctl(vcpu, KVM_XEN_VCPU_SET_ATTR, &vih); + } + break; + case TEST_TIMER_PAST: TEST_ASSERT(!evtchn_irq_expected, "Expected event channel IRQ but it didn't happen");