From patchwork Tue Sep 19 13:41:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 141988 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3510460vqi; Tue, 19 Sep 2023 09:17:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIj6sAOUWEjJDI0cE7G9ZCwlXCJIcw4B55+NTxyTaERC9Iq6dHfBMI8zkURJw8LyOmmJal X-Received: by 2002:a17:903:41c3:b0:1c4:4a58:ff65 with SMTP id u3-20020a17090341c300b001c44a58ff65mr13369158ple.64.1695140239698; Tue, 19 Sep 2023 09:17:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695140239; cv=none; d=google.com; s=arc-20160816; b=B6poMeqodiiRo6ffF4fs6VjhY868wfgpw49CjKLzQsOrDizqvpfYVk9dgtkmwU4+QN AKA0VRQzZ4c2o8zHgb72QIYuJY7yrluOPENCQKrJj5QF0d8J3znIE8Hg36SC/+LSrcqN cCU2nPmixPBO87qRtEKPd7CpklBufPAz6Pjf8/nV4LsCxShpSdYKH/zvMcz+7uVhhErf Erv6/xnZ1R98+5GAOEOjmj3fX3H6cCi8ecRZz7uLJJdE3WWKKWmHboyLI/vw9jITI+nj SNPjmrx/SzyjoWF8N0lPfypXXnJac95N5CQ9nP+HY0RfbSzFRMSSdc/q5mtXbu45DS0r mBdw== 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=RGkl3s+m6QQ803Sq5zfxO05XwCR0rwq9bcU2qbCs9YA=; fh=lKhNn3P8ZvksS1fElybz1iP8zlw6JVVQ9gjuN2JwMdc=; b=Tu1xaw2oWgQ4NDoueTbes8+FGShJ3F3g5wh/WezqICw7vu7onX2Jytc/suyUez0tqv xkHtqwozwfLQwqSLUspXX0ybNKPjE6jLnjN1hSWjmdwMZGNoaS7qDibA4UUgCbaKwJWO 1kZBJrfjXF/6+kWnz5lVT61Ox80InARYq+L0Hqg0Eygf0D7dE1zOxIBk1bTkpq+AmJC1 DHYPRwEJLzXZL+KGVuwtvsgbMfou3zmaLXLVfp8xGoAofrsX49gtG9MCAR1QWbJpq2XC 5Lf4AtMCIPySLu1mWmkB0jW/rg4kik6tlWGFVKYStxPm3cJIH4h04Yvht7M9Zq/dQvEj 4Y4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=EYVPA7ea; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id u15-20020a170902714f00b001bf1d1d99f6si9829102plm.358.2023.09.19.09.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 09:17:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=EYVPA7ea; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 2349E8280114; Tue, 19 Sep 2023 07:00:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232532AbjISOAZ (ORCPT + 26 others); Tue, 19 Sep 2023 10:00:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232437AbjISOAX (ORCPT ); Tue, 19 Sep 2023 10:00:23 -0400 Received: from mail.xenproject.org (mail.xenproject.org [104.130.215.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 915C983; Tue, 19 Sep 2023 07:00:17 -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=RGkl3s+m6QQ803Sq5zfxO05XwCR0rwq9bcU2qbCs9YA=; b=EYVPA7eaxhETNlYAlnnDPkvS6M F6wO5TM2a2ZkN9CFQRcNB+hQDiYP0Do8pm/rB1LIHxcDh7NzyJ90ruokn3hM21KckydiyvajJ5tps IhSvoyJwONuSI/qIJxtFgSZw261HrqkdngMNd4DdiEdA4ZU8e5kIJ/LuH28ETolZor9U=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qibGy-0004Yy-GM; Tue, 19 Sep 2023 14:00:16 +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 1qiazT-0005jy-Sj; Tue, 19 Sep 2023 13:42:12 +0000 From: Paul Durrant To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Paul Durrant , David Woodhouse , Sean Christopherson , Paolo Bonzini , David Woodhouse Subject: [PATCH v4 12/13] KVM: selftests / xen: don't explicitly set the vcpu_info address Date: Tue, 19 Sep 2023 13:41:48 +0000 Message-Id: <20230919134149.6091-13-paul@xen.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230919134149.6091-1-paul@xen.org> References: <20230919134149.6091-1-paul@xen.org> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Tue, 19 Sep 2023 07:00:53 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777483371981267685 X-GMAIL-MSGID: 1777483371981267685 From: Paul Durrant If the vCPU id is set and the shared_info is mapped using HVA then we can infer that KVM has the ability to use a default vcpu_info mapping. Hence we can stop setting the address of the vcpu_info structure. NOTE: We still explicitly set vcpu_info half way through testing (to point at exactly the place it already is) to make sure that setting the attribute does not fail. Signed-off-by: Paul Durrant Reviewed-by: David Woodhouse --- Cc: Sean Christopherson Cc: Paolo Bonzini Cc: David Woodhouse v3: - Add a guest sync point to set the vcpu_info attribute v2: - New in this version. --- .../testing/selftests/kvm/x86_64/xen_shinfo_test.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 e786fa370140..7e74b3063437 100644 --- a/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c +++ b/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c @@ -68,6 +68,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, @@ -327,6 +328,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]++; @@ -549,7 +554,10 @@ int main(int argc, char *argv[]) .type = KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO, .u.gpa = VCPU_INFO_ADDR, }; - vcpu_ioctl(vcpu, KVM_XEN_VCPU_SET_ATTR, &vi); + + if (!has_vcpu_id || !has_shinfo_hva) { + vcpu_ioctl(vcpu, KVM_XEN_VCPU_SET_ATTR, &vi); + } struct kvm_xen_vcpu_attr pvclock = { .type = KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO, @@ -903,6 +911,10 @@ int main(int argc, char *argv[]) alarm(1); break; + case SET_VCPU_INFO: + vcpu_ioctl(vcpu, KVM_XEN_VCPU_SET_ATTR, &vi); + break; + case TEST_TIMER_PAST: TEST_ASSERT(!evtchn_irq_expected, "Expected event channel IRQ but it didn't happen");