From patchwork Tue Dec 19 16:11:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 181099 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2074171dyi; Tue, 19 Dec 2023 08:55:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5eE1j/Vfch8syHJMx+Npm70Aa3E7B+rEQPP7zhQQ59SA7GlL7ioCLN2wQA7rCPXtpEUTG X-Received: by 2002:a05:6e02:1a4d:b0:35d:59a2:bbc with SMTP id u13-20020a056e021a4d00b0035d59a20bbcmr16344433ilv.82.1703004937260; Tue, 19 Dec 2023 08:55:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703004937; cv=none; d=google.com; s=arc-20160816; b=uvXcnJo2BZEQk1jycHiM7H9tGSbTcY1IzVaT0JTTRqvXvizmagKnTQMEpk+uSFj4AY Wg9VeH68DVLHAx7fC//wiKX8m4Hnm7lpb01l2ihizcIbXUVlPw7NWR9j/OgRgdMCr8Gw EFOwuDQ2r8REOHdYfYVE74GTXTZJHpJaMR2WmTB4+0B3rU7AUUzkahEYAIvvPMD/5Vtv bcs/Y48jRKy5jLaL6p8cskLfq+fODX5aK5eEBBJhg0J0k/T0HwZcqzzXh3+Y/+L7IRMf gpr9pB++9qcsZN0MFLrUEchuRoHAJaMVEWql6x5s/OHNHTdHUDBsm9MGn2Dz8oGAfi5j OOkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=nuXWSkr0ZyIsLCugqKNNY21HAlliCS4E2dntcvQyiAA=; fh=aAPqvXm40pY9772UiBOljEePwtz/3Q0zIOpw238tj3M=; b=ZFxk9lcfnCQ70vxw29sQ9lhpX7nnPgg2upQuV/pKOPVc5tb8hISSOXLNEGMX+Zvmz5 47jGv5sy6XbL+IwA5QWSq64r2R32BJ4OcwvmrsUMvHdEQt3+7+/gACLCv8pexXPCtA12 0FiDaLkbv9bYkzgrepHZ7bzw/xjzCWtLw852OFzbUnqmAY9M41uM4WyOrFK6IqV1zjDC eqheKlVfehhWXIKXC+IClM29zwQ1VlOJCwFR94syb2Rn39zmrKJBrVNahBDiZbTzipJy oxKm/veQW0zd/3ouupJLwxIG3VqDzIh0PzMGAzge1LNKNQZWYQBaUgXVpYeNNFmc/oRE gYnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=oUVOIAFa; spf=pass (google.com: domain of linux-kernel+bounces-5581-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5581-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t9-20020a63eb09000000b005bd04d27b69si19642820pgh.725.2023.12.19.08.55.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 08:55:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5581-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=oUVOIAFa; spf=pass (google.com: domain of linux-kernel+bounces-5581-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5581-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4EB6028AAF6 for ; Tue, 19 Dec 2023 16:44:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB9A3374D5; Tue, 19 Dec 2023 16:41:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xen.org header.i=@xen.org header.b="oUVOIAFa" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.xenproject.org (mail.xenproject.org [104.130.215.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F152C20334; Tue, 19 Dec 2023 16:41:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xen.org 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=oUVOIAFaNHVexNTFXcA8x8MFdy vkkn0/ldOEiPIARqQ+uoPXqgGxbRTTY9nnLXBIM9mTjduq2/pFUuE4gis186Fuj80AKt56i50Euey FVru3Qk6uLqN/IBQnXEfvK/vwwpUeZRsVj5zhwmEXIHZKzPWN2PJe4vOq5G104Wg4Kqw=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rFd9y-000653-7I; Tue, 19 Dec 2023 16:41:34 +0000 Received: from 54-240-197-226.amazon.com ([54.240.197.226] 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 1rFckI-0005h9-T5; Tue, 19 Dec 2023 16:15:03 +0000 From: Paul Durrant To: Paolo Bonzini , Jonathan Corbet , Sean Christopherson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , David Woodhouse , Paul Durrant , Shuah Khan , kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v11 14/19] KVM: selftests / xen: re-map vcpu_info using HVA rather than GPA Date: Tue, 19 Dec 2023 16:11:04 +0000 Message-Id: <20231219161109.1318-15-paul@xen.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219161109.1318-1-paul@xen.org> References: <20231219161109.1318-1-paul@xen.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785730105110145594 X-GMAIL-MSGID: 1785730105110145594 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");