From patchwork Wed Nov 22 12:18:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 168335 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1285573vqb; Wed, 22 Nov 2023 04:31:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEssdR+6px4/5o9qi9c4HTQB6Jw6+rzymdVPqhgETRBON+qH/PHIn4D0yli+3bps/DpESuT X-Received: by 2002:a05:6a20:a40e:b0:18b:2265:c6d3 with SMTP id z14-20020a056a20a40e00b0018b2265c6d3mr1678537pzk.36.1700656298782; Wed, 22 Nov 2023 04:31:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700656298; cv=none; d=google.com; s=arc-20160816; b=RpGlJwn7YgHBipLvGZBkJgyTQls9GM7m6ZrgGHBtYrZvpfruSQiQ2WHn77W97zdWiz VGd3eHp19N0KIVrKxfz2Iw4ulRleD1CJz37DpRn2Xl2y7/f9MUXytmzqw+vQEbmN6PW6 sDrtWH2g9ugJKtXlmZ3Ts6w22GwestR8wHxcRZBssx3DTD2rOZT2djbmgnGjpfYh9F+m XyoqKqJAQcf95DBYTnqQsv8XECwLNVItU+DsIYiHkLTqMO1GeWUIktHX+McbyjndHsQr gqnJKot8YkkLYoEUSUavWbQnxYEvsfmnQrTZjh9FswuUkansOU3BstkHTvR0kZucpYlK FbNg== 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=z0ZffTRllGc0QgvPkAKPmZxN71aZaequXcoYhQnfikm2d1V3wFZKoI7zJ055Z6Ivib Oew76E6iNIVIu8gmXkyEsyLHqcFtQon3S4rBqxsYHLAIRoLVtq5zaBGi74xdvyQ5uq/Q ZqP1nSko2LE7xbCVBsouDCuV/Zd/A1W9g09gA758q90ZUUze+EKIxMBXnScqVh1mcVpZ bft/jZmd8jl/Xy94rkJSF+4QSFA6Bk/gTwf4Fm8qmMZt80GqQReyPMV820vo1fCJDcc9 dNpFRlP1yvsEKv2IS+FmJB5Oay0RDQzJb1axSAlhGKSf4NTCgNFrADMgq/EBR2Eztu0I WAfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=hv+D7Up9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id o12-20020a056a0015cc00b006cb7f9ddbd5si7691188pfu.321.2023.11.22.04.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 04:31:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=hv+D7Up9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 69F4781C5097; Wed, 22 Nov 2023 04:30:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344088AbjKVMab (ORCPT + 99 others); Wed, 22 Nov 2023 07:30:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343719AbjKVMaa (ORCPT ); Wed, 22 Nov 2023 07:30:30 -0500 Received: from mail.xenproject.org (mail.xenproject.org [104.130.215.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DE7691; Wed, 22 Nov 2023 04:30:26 -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=hv+D7Up9ntPVZysdv4O/LvJKt/ 5Xg/cDAxUj70EHT6DD7GDQMitBuNFR1OoYUfRX7QxtgjzJ7FbEnGLKxE7h68tG/7WKdM9C0Km3pLp c2m8EENmgTnTVSDsYxa1XeAMAxiENThGo7jaYIiYtJ1JCmtP3zyHl6Zr91W20h+FzddU=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r5mMz-0005E2-UI; Wed, 22 Nov 2023 12: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 1r5mCj-0004y9-Rb; Wed, 22 Nov 2023 12:19:42 +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 v9 12/15] KVM: selftests / xen: re-map vcpu_info using HVA rather than GPA Date: Wed, 22 Nov 2023 12:18:19 +0000 Message-Id: <20231122121822.1042-13-paul@xen.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231122121822.1042-1-paul@xen.org> References: <20231122121822.1042-1-paul@xen.org> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 (fry.vger.email [0.0.0.0]); Wed, 22 Nov 2023 04:30:30 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783267379108279975 X-GMAIL-MSGID: 1783267379108279975 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");