Message ID | 20230926122013.867391-12-paul@xen.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2173207vqu; Tue, 26 Sep 2023 13:24:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDxTdweU+Tg7K8KXn8lNhIWs8sCw2CMcWDe0wvcNhmIm6pbuemEBUSX9Kh1yDzvMo1r0gW X-Received: by 2002:a17:90a:aa8b:b0:270:1611:484b with SMTP id l11-20020a17090aaa8b00b002701611484bmr7988791pjq.41.1695759849387; Tue, 26 Sep 2023 13:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695759849; cv=none; d=google.com; s=arc-20160816; b=abYwXEizFWO8yn1xVUeQsM6wlCHtdVL2/lbI+x6/JypZIx1E7YhYuxS4H0KuenAkmC Mc2qnTiyjCbdvcOh+7SSHCjBGqS91uIhyqcubdYLk5ABBUIXjDiNpXHtO3fKKEg7RNyz ZiOcETd64jVaRzdxYmLqrF07gCCgr8CPZTlJWS2J1qYuLVr3W8qj677qpx8uZSTPLuVq yo7fMqq5xXor6MjfDIPR+PQKPIhGzkPhKtsy1iQNfWqwZPr1VIgMCIZOptXWPdGokjuV 7eJrnxVXVI5tOifAdhRycYuaNeXXyAh4/eZxl/tTctT4UsbOknKetCRm/+LXO//UxVPX AlCQ== 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:cc:to:from :dkim-signature; bh=H9Vf5tNbaPBn7S/4TkOBeeLYEKwDTjy+c/p0HEaHmSw=; fh=F/y/rQAitAoVhyEvV7npxQC+pmk+LQOxsxEGW4WYgok=; b=ALl5b/rwNC4x9Umyq2FIWZ4Y3Mh8JMhayLc6B4ouWjzmfyIrFmvJKVjJJDix9O9PQO AUBntdXJ/kajM4aLER1sug4UYBuYHNUq41f7qBDCAkIRD118HQmalxDoyfpfdnKvy6HS 3PC0GpkFL3f1tmRL91eEzVSU6JdVaMKNoZqRdO+3BaJrBB4p7W45MgmCgVqGp18I2OXK WWW0J5Nk3gIqjxdeqsGKngpGbh2269xW5lA3Sz8+70bsmujKrKqmMrfRrqZ+8JktVhw5 vb0BhdL6JNbHEwEKg4AvZq2uCYdWlz5VLz/1e1zss8Woh1Z9K30HmlrtExKMFMaQtRmd 5sjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b="PT/68OFF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id p2-20020a17090a348200b00277507f542bsi6097072pjb.156.2023.09.26.13.24.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 13:24:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b="PT/68OFF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 9FA60808BE5D; Tue, 26 Sep 2023 05:30:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234616AbjIZMa0 (ORCPT <rfc822;pwkd43@gmail.com> + 28 others); Tue, 26 Sep 2023 08:30:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231171AbjIZMaY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 26 Sep 2023 08:30:24 -0400 Received: from mail.xenproject.org (mail.xenproject.org [104.130.215.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FB06FC; Tue, 26 Sep 2023 05:30:18 -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:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=H9Vf5tNbaPBn7S/4TkOBeeLYEKwDTjy+c/p0HEaHmSw=; b=PT/68OFF/DwJr72jWQ2Mq9AXwR wDseuJ9PdYMDnk1akKKtRNMMjXYvuDNYqj4yitauozHEk6hDhx2+lN1ZO46+J0fb2aWFgqhp6H+uP CBApzJ8WEymmuOJwAD9yjBK+2nellIXm/yT5GhOquwJEH3P885JV1c277OCA8S7/ehcw=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from <paul@xen.org>) id 1ql7Ci-0000Tp-Dv; Tue, 26 Sep 2023 12:30:16 +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 <paul@xen.org>) id 1ql73L-0001mF-Fy; Tue, 26 Sep 2023 12:20:35 +0000 From: Paul Durrant <paul@xen.org> To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Paul Durrant <pdurrant@amazon.com>, David Woodhouse <dwmw2@infradead.org>, Sean Christopherson <seanjc@google.com>, Paolo Bonzini <pbonzini@redhat.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, "H. Peter Anvin" <hpa@zytor.com>, x86@kernel.org Subject: [PATCH v6 11/11] KVM: xen: allow vcpu_info content to be 'safely' copied Date: Tue, 26 Sep 2023 12:20:13 +0000 Message-Id: <20230926122013.867391-12-paul@xen.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230926122013.867391-1-paul@xen.org> References: <20230926122013.867391-1-paul@xen.org> 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 26 Sep 2023 05:30:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778115806262333625 X-GMAIL-MSGID: 1778133079751212684 |
Series |
KVM: xen: update shared_info and vcpu_info handling
|
|
Commit Message
Paul Durrant
Sept. 26, 2023, 12:20 p.m. UTC
From: Paul Durrant <pdurrant@amazon.com> If the guest sets an explicit vcpu_info GPA then, for any of the first 32 vCPUs, the content of the default vcpu_info in the shared_info page must be copied into the new location. Because this copy may race with event delivery (which updates the 'evtchn_pending_sel' field in vcpu_info) we need a way to defer that until the copy is complete. Happily there is already a shadow of 'evtchn_pending_sel' in kvm_vcpu_xen that is used in atomic context if the vcpu_info PFN cache has been invalidated so that the update of vcpu_info can be deferred until the cache can be refreshed (on vCPU thread's the way back into guest context). So let's also use this shadow if the vcpu_info cache has been *deactivated*, so that the VMM can safely copy the vcpu_info content and then re-activate the cache with the new GPA. To do this, all we need to do is stop considering an inactive vcpu_info cache as a hard error in kvm_xen_set_evtchn_fast(). Signed-off-by: Paul Durrant <pdurrant@amazon.com> --- Cc: David Woodhouse <dwmw2@infradead.org> Cc: Sean Christopherson <seanjc@google.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: x86@kernel.org v6: - New in this version. --- arch/x86/kvm/xen.c | 3 --- 1 file changed, 3 deletions(-)
diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c index aafc794940e4..e645066217bb 100644 --- a/arch/x86/kvm/xen.c +++ b/arch/x86/kvm/xen.c @@ -1606,9 +1606,6 @@ int kvm_xen_set_evtchn_fast(struct kvm_xen_evtchn *xe, struct kvm *kvm) WRITE_ONCE(xe->vcpu_idx, vcpu->vcpu_idx); } - if (!vcpu->arch.xen.vcpu_info_cache.active) - return -EINVAL; - if (xe->port >= max_evtchn_port(kvm)) return -EINVAL;