From patchwork Tue Sep 26 12:20:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 14533 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp1870682vqu; Tue, 26 Sep 2023 05:25:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElV9ZSA3UUIiETGe21Duz+pJNphSNT1y8wjGFE0jaxLx2ijMIzLtOy1r75Vbr1I0i80/FW X-Received: by 2002:a17:902:d2c6:b0:1c3:a814:a12b with SMTP id n6-20020a170902d2c600b001c3a814a12bmr3506555plc.16.1695731123627; Tue, 26 Sep 2023 05:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695731123; cv=none; d=google.com; s=arc-20160816; b=nitXM2w12l9x5OItq7OSowCEbqOKvxxz8dNdk0CJAsqgy7QlRl1RIWpvlowFm/mhSe qB0QFQhX5y7oA7IDAAzJh0/YgI2pUP8dmeB69EXY6m+o9HBmUM1G2SxrvTLMQ5JXeKf6 uTnI4ZO7gaRi/WvmafpW2RtHene/U/GbgMLK0F6eNsl/jmskp+swS+9qKY67WGBpEXOD f7VOcj3Jwk3xE56uaK91GhJXGK806tfVOwzkFk9exIwYuuoKu3q+6yDkDAS9clvvWkDx XRqPBwpvnkm3OEM5599HClP22a3O7Ue5pRu9hNqNFS/Vj0vlyq0ivmSHQH2VLQXb1ESv sSgA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=w0YyJiw+O+zjquHaZvxAIGS0bC7/dphOHY+erwD9474=; fh=3Z3/5ePM9IQ2YVm9ac2TfhJPrOega/3SPNNrvynaeY0=; b=gWUSjGYKuV/bLNQXuZC2Pm2NkBnd7l+q5sDPO4b02H3NUTgC3ZOfmx8ly7LRDhWeZQ brb3kQAjp7S3s87XT0lIKSgcTjai7N0AQu8rL8FeJgP84TwdUA3EcID9CcGKcz0l8x8U Sj1ziU0cdPxqxRKf1BAVCSd+YlC0qjQHWuUrCoTVJCPZ7EqbnxGBqkc17gbPSasyR4SW MLGsv0W4HDzwijshjxOnSpGPTPZNDk4NnMzrQcwCU5vgPm5tPRY8zhKULqJTtnDDdluz q1Jl1xEAEHDXBR2rsxvXH4hcYOAqsbFz/a8bvwWOa8Q2z2AATaCMQBKdn2lCMZS5zY5O X6XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=xBKqfAiB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id c6-20020a170903234600b001bf0cc53d2csi12952897plh.261.2023.09.26.05.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 05:25:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=xBKqfAiB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 5093680293DB; Tue, 26 Sep 2023 05:20:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234569AbjIZMUa (ORCPT + 28 others); Tue, 26 Sep 2023 08:20:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230231AbjIZMU3 (ORCPT ); Tue, 26 Sep 2023 08:20:29 -0400 Received: from mail.xenproject.org (mail.xenproject.org [104.130.215.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63CDDEB; Tue, 26 Sep 2023 05:20:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date: Subject:Cc:To:From; bh=w0YyJiw+O+zjquHaZvxAIGS0bC7/dphOHY+erwD9474=; b=xBKqfA iBmX8ri+p/zTD5MvUJhspvsg3Hs9muE33AZemCF/OgeGJLZvi9ML1U4RvsEBY9RM7xyLOucvrWDhQ oj5yAlaUjASxZIg7BDgoxa4oPDwJ68AH9FUbz066WsiY6H7m98WmQw5e01gC5DXty9ytNgJiJFURk 2BLX72JHWno=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ql736-0000GS-Kl; Tue, 26 Sep 2023 12:20:20 +0000 Received: from ec2-63-33-11-17.eu-west-1.compute.amazonaws.com ([63.33.11.17] 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 1ql736-0001mF-Cv; Tue, 26 Sep 2023 12:20:20 +0000 From: Paul Durrant To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Paul Durrant Subject: [PATCH v6 00/11] KVM: xen: update shared_info and vcpu_info handling Date: Tue, 26 Sep 2023 12:20:02 +0000 Message-Id: <20230926122013.867391-1-paul@xen.org> X-Mailer: git-send-email 2.39.2 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Tue, 26 Sep 2023 05:20:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778102958506819084 X-GMAIL-MSGID: 1778102958506819084 From: Paul Durrant The following text from the original cover letter still serves as an introduction to the series: "Currently we treat the shared_info page as guest memory and the VMM informs KVM of its location using a GFN. However it is not guest memory as such; it's an overlay page. So we pointlessly invalidate and re-cache a mapping to the *same page* of memory every time the guest requests that shared_info be mapped into its address space. Let's avoid doing that by modifying the pfncache code to allow activation using a fixed userspace HVA as well as a GPA." As with the previous version of the series, both the shared_info and vcpu_info caches can now be activated using an HVA but the commit comment on "map shared_info using HVA rather than GFN" has been extended to explain why mapping shared_info using HVA is a particularly good idea. This version of the series also includes an extra patch to "allow vcpu_info content to be 'safely' copied. Currently there is a race window when the VMM performs the copy; this patch allows the VMM to avoid that race. Paul Durrant (11): KVM: pfncache: add a map helper function KVM: pfncache: add a mark-dirty helper KVM: pfncache: add a helper to get the gpa KVM: pfncache: base offset check on khva rather than gpa KVM: pfncache: allow a cache to be activated with a fixed (userspace) HVA KVM: xen: allow shared_info to be mapped by fixed HVA KVM: xen: allow vcpu_info to be mapped by fixed HVA KVM: selftests / xen: map shared_info using HVA rather than GFN KVM: selftests / xen: re-map vcpu_info using HVA rather than GPA KVM: xen: advertize the KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA capability KVM: xen: allow vcpu_info content to be 'safely' copied Documentation/virt/kvm/api.rst | 53 +++++-- arch/x86/kvm/x86.c | 5 +- arch/x86/kvm/xen.c | 92 +++++++++---- include/linux/kvm_host.h | 43 ++++++ include/linux/kvm_types.h | 3 +- include/uapi/linux/kvm.h | 9 +- .../selftests/kvm/x86_64/xen_shinfo_test.c | 59 ++++++-- virt/kvm/pfncache.c | 129 +++++++++++++----- 8 files changed, 302 insertions(+), 91 deletions(-) Reviewed-by: David Woodhouse