From patchwork Tue Nov 21 18:02:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 167897 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp834030vqb; Tue, 21 Nov 2023 10:33:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6R2n2y/Put3FfSbh5A8D4uJbi2K7gBCPIZZp8lJVeoc6xYhBNUXceqHG79/bY8wCZcgbX X-Received: by 2002:a05:6a20:8e22:b0:18b:246a:d43d with SMTP id y34-20020a056a208e2200b0018b246ad43dmr772245pzj.15.1700591626376; Tue, 21 Nov 2023 10:33:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700591626; cv=none; d=google.com; s=arc-20160816; b=TNQ023Dg+ByvogrsQCS9T/zyIi04SZGCu1DXr4rjZLxmjit7bYt2Ym+rbglKiKutYJ o/W4jIOZ3BmbW+CDTCC3mW/5Zi7kUdBWy9zAHNbcIxUVTunw5e36CZFHKQFK0cuilN8v s2XvLKjyUde2LjdAgTVF77faN6bmZJvpUfoG9oDe6d8M8WZ6QTuMbcZxxLK/pr/WtjQP PYBQyuPE3TQEGR9TekeGwYg1ZXznqitUckt+ZEmGxyoQt0qtJD4CshI/xfJv/BszXfYj zDoylpdG0gTz0kQKlPomz5IODPpmsftzMkrUsIqVQDeBMMuLcjtTfWCrN4eJ4JQH22wz PkUw== 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:to:from :dkim-signature; bh=nuXWSkr0ZyIsLCugqKNNY21HAlliCS4E2dntcvQyiAA=; fh=Cum1qOF0YrAzH/5yQjcCBfU63B+V0l01YtzsDBRUOAc=; b=atPwgEdhC+AN/8apf8DMaK0qvAOfqLjpGpUhNE2Wal4eGdMug9g4vk/upQz8Mf3vT7 wZlmQh7IFF8mHZI4VK1E3xK9Xj5aT9mvjUQ1icZ04Dkw40IEbed6sWlY9I6+8wRmIQtr xHVI9wNBY5v4O9PxG0jbFX+XwpbORghvjo+Fd+xLlh7OOIFfIqMnMFuQPNSU/8Raymcg pBAcfzBQe38qUASIB1v7kmgf+f/wQGOXXqsGV12dFQEJh9YVQmH2KZF5MpljJD5fLsr4 80bbiAB4TJgX+F44muvh+Zj5rtkdn5EazGi5eppWTFchkbzks4mBbA9+YK8Sz3alLtYv tEYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=si9CZElJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id j12-20020a170903024c00b001cc54873f98si11314980plh.149.2023.11.21.10.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 10:33:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=si9CZElJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 471D48028D6D; Tue, 21 Nov 2023 10:30:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231236AbjKUSan (ORCPT + 99 others); Tue, 21 Nov 2023 13:30:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231178AbjKUSad (ORCPT ); Tue, 21 Nov 2023 13:30:33 -0500 Received: from mail.xenproject.org (mail.xenproject.org [104.130.215.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80C88193; Tue, 21 Nov 2023 10:30:29 -0800 (PST) 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:To:From; bh=nuXWSkr0ZyIsLCugqKNNY21HAlliCS4E2dntcvQyiAA=; b=si9CZElJZwCF2DGs1y9Dgxfkcm Fm3N8P8qmVPS6fA47Ir8YQBVIG/V4kihJIgX+LQ4hVv0RR0dQU7hsG6KoF/qsL3cZ0vW6mKI3eQCH 3W3wANpemSfMY6oV1lcuYjwRy7tNjlfJd6tuEBD3ca/iv5VcmjvmsAVTzV0iAxqrxzfY=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r5VVp-0000Be-Sz; Tue, 21 Nov 2023 18:30:17 +0000 Received: from 54-240-197-231.amazon.com ([54.240.197.231] 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 1r5V5o-0004Z3-S9; Tue, 21 Nov 2023 18:03:25 +0000 From: Paul Durrant To: David Woodhouse , Paul Durrant , Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 12/15] KVM: selftests / xen: re-map vcpu_info using HVA rather than GPA Date: Tue, 21 Nov 2023 18:02:20 +0000 Message-Id: <20231121180223.12484-13-paul@xen.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231121180223.12484-1-paul@xen.org> References: <20231121180223.12484-1-paul@xen.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 10:30:53 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783199565186954682 X-GMAIL-MSGID: 1783199565186954682 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 a61500ff0822..d2ea0435f4f7 100644 --- a/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c +++ b/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c @@ -62,6 +62,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, @@ -321,6 +322,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]++; @@ -888,6 +893,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");