Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp573704rdf; Tue, 21 Nov 2023 10:04:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGk61QEsXxUPED54z3Xc2ZCP8gaHCp0g4e8pxNln+ozQF4y3wj2VNMZDm0XuMdjVxRn4YNn X-Received: by 2002:a05:6870:3c1a:b0:1e9:9215:3987 with SMTP id gk26-20020a0568703c1a00b001e992153987mr29189oab.16.1700589842568; Tue, 21 Nov 2023 10:04:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700589842; cv=none; d=google.com; s=arc-20160816; b=GewRK5vgD0XM3wbhSYFaqNtGo6DsZhlpIHxcJMPapdLH2Wm35Q4Prn8UME4EUvBUcd 9OcDtkN2CRpTF3WT3pIkqjqv3oay81uWE3ZHhtRm2OvVaG2oDD8J6vvkQ70xldB33vhA dlVBgGdZTCjzY5FkslgHeKxaSNjBNPnLcd1OiVG8PlL5wQLoCpw9w/WspFeMF7zHBN6x BRj5uPnfICoyEGdPGY8tZqYQkzIkVq3+1r03HnWZJAec6XpMOfjM1qOqqA/Ycf1PDNWR dyTO0n59V4dnT8wgjJmQ7aiDkJKhXfEKjRqD65g+elhL0T0/L8WD0v5cnIb+dgDMS0AL Or9Q== 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 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id v16-20020a9d6050000000b006c4e71cd1b9si3626667otj.127.2023.11.21.10.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 10:04:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; 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 23.128.96.32 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 DFA6A80D159E; Tue, 21 Nov 2023 10:03:38 -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 Content-Transfer-Encoding: 8bit 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:39 -0800 (PST) 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 -- 2.39.2