From patchwork Tue Sep 26 12:20:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 144886 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp1919834vqu; Tue, 26 Sep 2023 06:34:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHcHRluXlmwzphwfo3qhUHVuSn2+kKMSjsSRktOmowWzNr/aXiHoHk/1b6DyqaB6p32y6Sw X-Received: by 2002:a05:6358:591a:b0:143:9bc0:a975 with SMTP id g26-20020a056358591a00b001439bc0a975mr12479932rwf.7.1695735252756; Tue, 26 Sep 2023 06:34:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695735252; cv=none; d=google.com; s=arc-20160816; b=jpRRAfbgpXji2oD02R9J43Ndr6AZ6uqMRtI9Y7wPDpnLcU2a8LOUOgnMqXHTE1271N s5wTmInzV7OWaqxVW6/r/9rOBXzBDGCc1UOLEi6Vb4LWhdyiX7pyAFK7WKmXyYgka+TZ jWFwvuVlGxVZBhvqOiOHv8zK29VTJ8w/fEzvU2rOY4q1L2dRVkVMwngVHsbKq7uJnLgg N1/u+VcAsJjrXFrJ3nLWOQORUgPY3X3E691KKT1JD2Jqtx1XqusTMs+JCJ7B1gfdGWQu n8QSy4d1JyR/5mPeQaZ4hWhxIqNueCwIy3Q7go0BOvWcGfuCo4vKxQPcb4YflAyFDoOn MChQ== 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=GVRP7ZhX9y66fV8la0Z0phq4YOuv61LMjBgGZkw2zl4=; fh=lKhNn3P8ZvksS1fElybz1iP8zlw6JVVQ9gjuN2JwMdc=; b=Z497AT3jlMGlpUOHHH02IrDe5p/TgP0faJjPdvC+ve5AeJ+FFjuHPsOEIbkYsNiugS q9TZugQfxmnkV8mfXZbVG8JMQvaJsHrb8koF5g6DY17YBuu30oz2Kz7BgdnAKVx34pZb 0hSfautFPvXk2VGroDoOkXt7GDiUVjgXzWjVrOT8lkDOk3L59uWfgKKjSDwa/owGDCHP wTXnbGdfFEjCwW4bE2b46ts9pZfjkBgdw+PUEaL5B9QAPbF5aVLvDtycBELMR5ZuLhfC 28HbHp4xwccK8R44/AfLkPx2Oepz5YA6sVNh1dQhkRWaJGALsho+pzA1xQjQXZXqNn85 xmFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=rj2urSvr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id bk13-20020a056a02028d00b00565360714f0si10549356pgb.902.2023.09.26.06.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 06:34:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=rj2urSvr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 777DA8370D80; Tue, 26 Sep 2023 05:21:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234663AbjIZMUy (ORCPT + 28 others); Tue, 26 Sep 2023 08:20:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234608AbjIZMUl (ORCPT ); Tue, 26 Sep 2023 08:20:41 -0400 Received: from mail.xenproject.org (mail.xenproject.org [104.130.215.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B423126; Tue, 26 Sep 2023 05:20:33 -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=GVRP7ZhX9y66fV8la0Z0phq4YOuv61LMjBgGZkw2zl4=; b=rj2urSvrvK6H++zO04aJR9h+9T EkFDrmH3fH6pu6WNr9oi0CobGOYQzl/7mmqEXBu83s1Cj+i728wbadosNbhxm8jKHMsRmK7R83k9v xoi03HNc3qOMIf3rxRJmbX+d92Tu7TV6zGanD5irxQLUyPE51H5zSe1CKp5tvY+1jz3c=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ql73I-0000Hm-HE; Tue, 26 Sep 2023 12:20:32 +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 1ql73I-0001mF-9r; Tue, 26 Sep 2023 12:20:32 +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 v6 09/11] KVM: selftests / xen: re-map vcpu_info using HVA rather than GPA Date: Tue, 26 Sep 2023 12:20:11 +0000 Message-Id: <20230926122013.867391-10-paul@xen.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230926122013.867391-1-paul@xen.org> References: <20230926122013.867391-1-paul@xen.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Tue, 26 Sep 2023 05:21:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778107288231008403 X-GMAIL-MSGID: 1778107288231008403 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 Reviewed-by: David Woodhouse --- 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");