From patchwork Thu Feb 15 15:29:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 201583 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp488951dyb; Thu, 15 Feb 2024 07:48:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUONkjAZ6mRkQjMySsRxAbbAe+pItwtIysMlnJFrU4Dp/xVqyUQhU8WCdnfcA3xrFU/kMIs8yE8uGSB2PN2iNg2NCpBwg== X-Google-Smtp-Source: AGHT+IGSzZbC+mW8FgUGRyQbo5iQP5ENmHC+FD9ARo3m0rz32XOA0dQG/okYvuR1MCmCNLFtvfOy X-Received: by 2002:a0c:e40b:0:b0:68c:ab0f:910 with SMTP id o11-20020a0ce40b000000b0068cab0f0910mr2403285qvl.55.1708012113984; Thu, 15 Feb 2024 07:48:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708012113; cv=pass; d=google.com; s=arc-20160816; b=w3mZ9mlTvhBQnw7xuKtIj1W5/cFFWjisojgrD7Ime7b4HdvMDMqaf5YVkjvZyyB5Nb Xl/pbjAVn5z33/ago5zOZtg6WNkKRGEEENj3VEZ3A9tVWwQfqBWc3hr5rkLPihid7bX3 mKFWQweGZFaa+RaHoyCn/zxpoEEXKWTqhSKFiOEH1QlIEWo32oUjDapjuDDUAyy58RPM Exgy8RuU27Wv/WkpAyp6p907aMaAlFoHRA2UhbVXkBUuhHy8zDQrfPl2AlmaCJ+ujTGR tbnk1S0NcCvcuKNx+qAXIzhO21L506ikhKOg7gXW55TnnCCJ1twL2C7rmlGJNqQ9CKJ9 uQcw== ARC-Message-Signature: i=2; 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=eGccA33nyFEKdgeK/g8u1BZPB0MRYMmxx5o4P3mI8s4=; fh=NrOggL3VZvuSFh5W9Wj2+kLgS4v0nogfnAWvBJoouXQ=; b=cYBEiEU/h8zGnnL+HFYfEt4XDE0oaMtxImJ1Wo3r+QcrfvRl8I0BRN2lZBUkfrOoBU cUEYPotJzCK7zTgZof1X673PYBpRa15bF30YZAxLHdQvdf620ZhBtlMOFpC9PRKfRcAd DPKyC6MI4+ElehBDVkPZZ9WvC+ft7V//jdgo9a8/QQqQpl67iFJGPIOUE0oND8Eg2JcY HKWVrte6McOKlbS7uKFfWRtUPlhYCByhqs6mWZuKFJ+4xToKh6ODIqHN738H85fRgrD8 ABwH07XgbC2Za94YO/L8cwadJzz0ssYQjmEJv/BKHP1v2Uc8HCN/bjRTnDaysgtqjUwn accg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=egrlIkVf; arc=pass (i=1 spf=pass spfdomain=xen.org dkim=pass dkdomain=xen.org); spf=pass (google.com: domain of linux-kernel+bounces-67231-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67231-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 15-20020a0562140d4f00b0068f2dbe3675si87139qvr.347.2024.02.15.07.48.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 07:48:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67231-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=egrlIkVf; arc=pass (i=1 spf=pass spfdomain=xen.org dkim=pass dkdomain=xen.org); spf=pass (google.com: domain of linux-kernel+bounces-67231-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67231-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C0B201C2356E for ; Thu, 15 Feb 2024 15:48:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC45C13398C; Thu, 15 Feb 2024 15:44:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xen.org header.i=@xen.org header.b="egrlIkVf" 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 E52FC134CFC; Thu, 15 Feb 2024 15:44:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=104.130.215.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708011877; cv=none; b=gd7pvM4oCL4vv0c2lrmRJUSl9QmgZnbj2TzXLYSDTnEFdVJfr6CNHkVq+TbkLWWbqgjAvhkpacIdHmgbXpck71nHAXBnK75t8JOVqHcz0/1lA4KyV05zWRtxqFwo2PbPLyZ4EYwZ6V20+1BLBFZGc6d5Zl1qQJ4G3rvcLFoJsak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708011877; c=relaxed/simple; bh=6njkDDjVH7BF5Vtv3rgURx4yvTEOIoCdz9lB2ougXog=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hWeZqoaYrzciH1QO+1u7DqcYBRwZS7HNijFOwp2e8H1u0QAf8/cOHTQsSKKhgomnaUSNyQZtOXadJE7SDwpAGUHanJXYBqM7EcryqMk7ozrdDtPYM365QE3P8Uf63ODZhjMFxqmE7STQI1ZZfCG2t7IZB0QimLyMZDWD/vxeE2w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org; spf=pass smtp.mailfrom=xen.org; dkim=pass (1024-bit key) header.d=xen.org header.i=@xen.org header.b=egrlIkVf; arc=none smtp.client-ip=104.130.215.37 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=eGccA33nyFEKdgeK/g8u1BZPB0MRYMmxx5o4P3mI8s4=; b=egrlIkVfX67JoHldpFJLL3GD0I eYtq30dEdsjEVCpuyXGLNG4LjQMl4eZSODnmvt8roh3JF24Gm7BIq+Hkcak8QRSOFt1YGtnQcE1Di Vzl7y+vGzT+N9DYmDNG7JCX1U+LYvwPtK2wTKo/jNMtYFQSkSPI5X8BGkMRji4bPxWbc=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1raduL-0001WE-IS; Thu, 15 Feb 2024 15:44:17 +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 1radhN-00089r-D1; Thu, 15 Feb 2024 15:30:53 +0000 From: Paul Durrant To: Paolo Bonzini , Jonathan Corbet , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Sven Schnelle , 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-s390@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v13 15/21] KVM: selftests: re-map Xen's vcpu_info using HVA rather than GPA Date: Thu, 15 Feb 2024 15:29:10 +0000 Message-Id: <20240215152916.1158-16-paul@xen.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215152916.1158-1-paul@xen.org> References: <20240215152916.1158-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: 1790980510560479979 X-GMAIL-MSGID: 1790980510560479979 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 v13: - Patch title change. 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");