From patchwork Mon Jan 15 12:57:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 188145 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1692553dyc; Mon, 15 Jan 2024 05:12:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHnp/P1nO5j+rOYssexneppvoEwLEDLG0KyyDMrY6hkNxis4JhTk5ruloS5eF2FX3OAFt9/ X-Received: by 2002:a17:903:247:b0:1d4:ebc2:5156 with SMTP id j7-20020a170903024700b001d4ebc25156mr2607171plh.21.1705324353054; Mon, 15 Jan 2024 05:12:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705324353; cv=none; d=google.com; s=arc-20160816; b=ndWjXW8vHOYCaXLP/qmnGsxy3ffz37kUUmTu849NUop76pAZMcPHBOpU7n853UKnRD AuOm62t5eYtpL4mrW+rptDnsVn8bbZKVK2cbcp96D0u64hAcNWLPGQGzmI1uPK1L+Cyt ulGiZXMl0h4Mwpzorfw0xMVelULmPcZSsXuQzWArJyYu0QWMmAqTLRveGm1cUgQRuN9m 9VPDcKAVqHY+7J77xJWjtbvG7UGceevS43braUrsqfVeKNfmVVVfZmHI+tRVrYRSpHRW l6AhxaWgmSZ7HIRtwiJypNCpBj3AGXPn2T6/uCv2HNI9H6fPwuaFVr7KvlesQPqsD74x ZieA== 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=lhnmT7Le7OKocPSPh8YPntQrnDHy/WAIs6ck8o6OM+0uU71Vdx8g2vfsUh9ZYKi9gv JjHGGodZExI5inWqcbCVFW54m1EvJWnsP0CLnH4uBjHTIHSKYKlJoIY2dQ31SXZNxoL6 fGIlOkYsadfibd0TFWOQpTWjuHLm5wJrZg7DkbbzvV6C1pQB9t9GbzJrcocWhK37UjFx CgVSeYkDDjDwcf92z/A9arDXbKwU/LZRVju8Rl8e/MP1yDK62bTykq2kWe3Fn8AryB7S 3b5G9mdW48ndFhL78jxmDJGxsJTuuwxP7DaS0ffNL+tIfNIJwOg+mtUhNAUv7Ja90xLq 8FoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=uGhlY9Jz; spf=pass (google.com: domain of linux-kernel+bounces-26002-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26002-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id kb16-20020a170903339000b001d4c4e691c9si8698224plb.464.2024.01.15.05.12.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 05:12:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26002-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=uGhlY9Jz; spf=pass (google.com: domain of linux-kernel+bounces-26002-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26002-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 19F63282604 for ; Mon, 15 Jan 2024 13:12:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E9861804A; Mon, 15 Jan 2024 13:09:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xen.org header.i=@xen.org header.b="uGhlY9Jz" 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 C2B4B17581; Mon, 15 Jan 2024 13:09:45 +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=uGhlY9JzhsqDmyYkZRE14V59pf ux2RS/X3JHbTnEOhe/qq9fKwwfxR8+eQ9m5+oAGxTv8CIRfOOz/F3lhLy5u+42ZzSCEMJSackDaNo fsqhE5H/fvCgAagTeOsPiKQdgydZGMbhmkAQhnwj43YU2OoR5z9Db1P6LpbW7ROB1crI=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rPMiY-00035e-OO; Mon, 15 Jan 2024 13:09:30 +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 1rPMXW-0002kM-Fu; Mon, 15 Jan 2024 12:58:06 +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 v12 14/20] KVM: selftests / xen: re-map vcpu_info using HVA rather than GPA Date: Mon, 15 Jan 2024 12:57:01 +0000 Message-Id: <20240115125707.1183-15-paul@xen.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240115125707.1183-1-paul@xen.org> References: <20240115125707.1183-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: 1788162189067307936 X-GMAIL-MSGID: 1788162189067307936 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");