From patchwork Mon Dec 4 14:43:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 173428 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2819170vqy; Mon, 4 Dec 2023 07:01:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IGyMkDySRGSJuHZFdoMgsKTp6tjTocTT9SS+0NqJuSIp/csAdJ/c4GbzmpIlPo/bDCeiXPH X-Received: by 2002:a05:6a20:258f:b0:18c:64e0:4408 with SMTP id k15-20020a056a20258f00b0018c64e04408mr2025597pzd.44.1701702071594; Mon, 04 Dec 2023 07:01:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701702071; cv=none; d=google.com; s=arc-20160816; b=W9XxQ6q+c3q0G0O2CtvVPa/AuIfR6Yg7gpHIcOfXxNslc0QEYpso9hJahn4TUMeTi1 fTeAi1MAtZlfJvayXiVmQGPBiyBfRfHVRjr8EHtB5rWiozl0diBlNZc4AUhOpu13RCkM DfaQidk8EM6LcBRcfN0Cb5h5eGHa40fBIUvjCMFGv45L2TEH+Q/1gS7C41kW9OifH9cx 0ULG9eyrWgD4qIvTEGZodOCfXL1JZIA1GKTkzIZ5duqi5+oG6SbEQaUPZQuPUl951Z9U S98+k2iOGkimlThn8pnRvrBRzv/DG1wxFhyZYGgxJMTb1+LREF/fW/Affmk8CbAUmc8L 1EmQ== 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=aAPqvXm40pY9772UiBOljEePwtz/3Q0zIOpw238tj3M=; b=BxBh34B9/qpZXT+IkjotZCNiI5aEd2u8v4lrXfBzc1/4ETx0yUmY1VfXHHTZAbC5iR gQXI0ai8xDEsh0aBpjHUjELapagWZhvvgkE2w6BkNit78PTdC2SXhPboC5WnA/DboCx7 Jq0hmZNY1sSO79x/3uOkJ7XW/Llc2NJ+q0x/lELFUYGF84NCRQ2jftP1kWGp6e1n/d5q u5KT1bezCbx5RUg3iVT66yTXJ/bcYo63h2wAQIL8wP/n4jkDOKIWGC318mun10gReFIo NszoY/xOZvwuC6LSFymoyINrW1Tij5fAPR58czRtFRkcrHMKoLbmhF5klIltYWvEbRxp ctOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=I+E8ThFu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id s1-20020a056a00178100b006c4d1f0308bsi8078034pfg.262.2023.12.04.07.01.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 07:01:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=I+E8ThFu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 6B1E380BE7C2; Mon, 4 Dec 2023 07:01:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233734AbjLDPA1 (ORCPT + 99 others); Mon, 4 Dec 2023 10:00:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233591AbjLDPA0 (ORCPT ); Mon, 4 Dec 2023 10:00:26 -0500 Received: from mail.xenproject.org (mail.xenproject.org [104.130.215.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59CDEB3; Mon, 4 Dec 2023 07:00:31 -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=I+E8ThFuekmllmO8UyO+Fs+7Q/ DktKO1OiBU1y99hjK+piiY2BeaGE56MMn7HhWUkspKMtMUod04zqVh7QdHhar5BJjxNn+2I1BQ0vU 08clVVMIOqaHqaItxzBqh0lybPG119fE3ZYFQP48l8TiMIXDBDE6jzbbAJoE7VWCkl1g=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rAAQk-00043h-RW; Mon, 04 Dec 2023 15:00:18 +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 1rAABP-00088g-Qq; Mon, 04 Dec 2023 14:44:28 +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 v10 14/19] KVM: selftests / xen: re-map vcpu_info using HVA rather than GPA Date: Mon, 4 Dec 2023 14:43:29 +0000 Message-Id: <20231204144334.910-15-paul@xen.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231204144334.910-1-paul@xen.org> References: <20231204144334.910-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 morse.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 (morse.vger.email [0.0.0.0]); Mon, 04 Dec 2023 07:01:07 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784363951611263390 X-GMAIL-MSGID: 1784363951611263390 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");