From patchwork Tue Nov 21 18:02:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 16876 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp814232vqb; Tue, 21 Nov 2023 10:03:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRZqHalHz3d4oN2sq3jV7au1RXZrFGVUaBADzR3MndDRuzlXAh9H1YD0puWcxchK3igXun X-Received: by 2002:a05:6a00:887:b0:6bd:2c0a:e82 with SMTP id q7-20020a056a00088700b006bd2c0a0e82mr11872394pfj.7.1700589813420; Tue, 21 Nov 2023 10:03:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700589813; cv=none; d=google.com; s=arc-20160816; b=1JcoW3Ki4JygaY4deQcuUN/u6xZ+MYQW5vv+V4vfU8VBxnuS5MT1uE94m/NaZU1GBT iCbX9UmtgP7blDat83Jelrhq2hFLlhtNrVCLsikTiv3WegvwyulA/qjSmsdl6oHu75zJ 9jRSnJmyAAEdEz2dFwEJg8/gYiyih+RK6Wv71VmBYiAAZSbf2RLqJ8x9OsK5pBJBxQaE kNZMnFPwFGkfYc54Z8DaEGfN4R8OQA5WBojzHHbTbuvbJqe8/9K4++2CKE3+15SYGvXo IruNaK3thspEBlSnxVu61/1IA4qR4x3Xwvts0p+eUZDD3lxRD2+3kP8qr3tsXcHM8tkA MJ8w== 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:to:from:dkim-signature; bh=ApY+rn3G/nOW/ld6052bD3LXs+qXCXswGYK8qsPr9M8=; fh=Cum1qOF0YrAzH/5yQjcCBfU63B+V0l01YtzsDBRUOAc=; b=LX/oIXV6oyWPVrvFhx775z7wiLjnaqXme/ezQDYZ7llCZNAQglLdnHjbDOTKE13ng6 0q0OKS0hem3K1VN/fXiSc0BkdvgMb3o38SudrOp1tfLixe2TxR2Zav0uRoyS7dWhULLh Ri0B7FZH+mrHJ5IYj6J/PlUrQ7eVCUR2UOhsJPksuBs5GgbMxIHhbWeYmD/YHG9o1uSA 9aQkjs5rgAXQ1w6h+l7wblQq2I8GKYfCveu9GiLuXXJjXDXbbSxlST/yguIWkD7Mx7Ou TEbLvU7gGEsSxVYg6b+ZuE+zw8m0Ek7zpBG1laCu9vZK97Q9yHFkfwX9x0x3VlARz4Tp u1GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=BrFgap+s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id fc7-20020a056a002e0700b006c3fb206949si11020393pfb.209.2023.11.21.10.03.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 10:03:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=BrFgap+s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 3A95180D15BE; Tue, 21 Nov 2023 10:03:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233504AbjKUSDW (ORCPT + 99 others); Tue, 21 Nov 2023 13:03:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231236AbjKUSDV (ORCPT ); Tue, 21 Nov 2023 13:03:21 -0500 Received: from mail.xenproject.org (mail.xenproject.org [104.130.215.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7DFD12A; Tue, 21 Nov 2023 10:03:15 -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:Message-Id:Date: Subject:To:From; bh=ApY+rn3G/nOW/ld6052bD3LXs+qXCXswGYK8qsPr9M8=; b=BrFgap+sw l2nTXG3eNcovUHWIq/QdZUWWLOEwzARgJIvGAzWfqKdh4cm6B1E17W8e7MKOKhSPGiraP/271NlZh JXk25UAl6JubDkoZMMgMi5Jd7ydqCskLs5XMcxJkwFJSPSsqtgQlHCCxSmfojKgpFjkhpr/mfDp9Q 4ILkQ9iU=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r5V5D-00083I-Cg; Tue, 21 Nov 2023 18:02:47 +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 1r5V5D-0004Z3-1u; Tue, 21 Nov 2023 18:02:47 +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 v8 00/15] KVM: xen: update shared_info and vcpu_info handling Date: Tue, 21 Nov 2023 18:02:08 +0000 Message-Id: <20231121180223.12484-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,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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 21 Nov 2023 10:03:21 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783197664201506784 X-GMAIL-MSGID: 1783197664201506784 From: Paul Durrant Currently the shared_info page is treated 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 the pfncache is pointlessly invalidated and re-activated to create a new mapping of the *same page* of memory every time the guest requests that shared_info be mapped into its address space. Avoid doing that by modifying the pfncache code to allow activation using a fixed userspace HVA as well as a GPA. Version 8 of the series has been substantially re-worked and includes several clean-up patches, particlarly the non-trivial clean-up patches: "pfncache: remove KVM_GUEST_USES_PFN usage" and "xen: split up kvm_xen_set_evtchn_fast()". Each patch carries its own version history. Paul Durrant (15): KVM: pfncache: Add a map helper function KVM: pfncache: remove unnecessary exports KVM: xen: mark guest pages dirty with the pfncache lock held KVM: pfncache: add a mark-dirty helper KVM: pfncache: remove KVM_GUEST_USES_PFN usage KVM: pfncache: stop open-coding offset_in_page() KVM: pfncache: include page offset in uhva and use it consistently 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: split up kvm_xen_set_evtchn_fast() KVM: xen: allow vcpu_info content to be 'safely' copied Documentation/virt/kvm/api.rst | 53 +++- arch/x86/kvm/x86.c | 7 +- arch/x86/kvm/xen.c | 260 +++++++++++------- include/linux/kvm_host.h | 38 ++- include/linux/kvm_types.h | 8 - include/uapi/linux/kvm.h | 9 +- .../selftests/kvm/x86_64/xen_shinfo_test.c | 59 +++- virt/kvm/pfncache.c | 175 ++++++------ 8 files changed, 374 insertions(+), 235 deletions(-) base-commit: 45b890f7689eb0aba454fc5831d2d79763781677 --- Cc: Borislav Petkov Cc: Dave Hansen Cc: David Woodhouse Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Paolo Bonzini Cc: Sean Christopherson Cc: Thomas Gleixner Cc: x86@kernel.org