Message ID | 20231204144334.910-20-paul@xen.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2819746vqy; Mon, 4 Dec 2023 07:01:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGlWOXawQyRWZmdX3Q5p+xQXHQR2Vzt5TJ9jEiP2xcNl0i9juv9/1pr0I1ghFK1P6c6uc4W X-Received: by 2002:a05:6871:4318:b0:1fa:1db4:5923 with SMTP id lu24-20020a056871431800b001fa1db45923mr4736392oab.43.1701702106480; Mon, 04 Dec 2023 07:01:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701702106; cv=none; d=google.com; s=arc-20160816; b=kK4oQ/Sqkz+KETw1p+DTLrET9kPJKfeK/D7RmNAX3eqUcL4Py7jRsO0f1YofRzbnxq iLc0vdVCFX/7Bz527aioe8OXgABZz5Ls1EYLS5IGjf+/Qw9uT6shvbQJOjq59zjkKuet sDOQ21H0dYyEskPhoyCm9MplStjh4IwZfY+3yc00gU4hsu4eAbvmtdi2iDHdnaW6i2BL 8WmAwd+hGrmYEnzcI3ahAi8vOSklpJt59YaXB2YN6UBlMQRWuX7e+RtbuDKKYwxEUAsP 77Oqk/zY55isSKiofWlfL28/oRk0dpZsd4YgJPXxAHwf/TLRa4KKrNd38nO6l3n5xWKd Imkw== 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=u3xu4cWioGlm/0Nl4ZRtWZZdIjjd8j62hC7w6zJEnu8=; fh=aAPqvXm40pY9772UiBOljEePwtz/3Q0zIOpw238tj3M=; b=nfVYACLUxSrQmOBYZKgfR1YQwIv1GIglEKp/wuX2DaJ+19dNFRqiumfiXtYaXAfWPM GChb5rtXc2OvKQw3x7lhde0CIO31ZALGzrW6OsampIlAlzc+zwpMN6WicRzExX0uJphR LtOvE45e+3QYTXFYnP1HLr1bFjf0+/2zD2EgpKYy+PsOomhyLjmBhc90R7Qs4YHEEBwv Ga+0oOU9oI0jmn7ZTsnPHUxHPE4eB2rfq76kJkroyD0OaUgAVnnxGTmD448KY3vScFQK hjVjAtuhS9dRwYzKrvJQrZroMYhnsLcWw7T66eRoumieoWDSqkNlIzt44jTX8EmWnRuf ek4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=BXioIzqW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id l14-20020a056870204e00b001fae826cf11si2451119oad.76.2023.12.04.07.01.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 07:01:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=BXioIzqW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 4B4BF8096BA4; Mon, 4 Dec 2023 07:01:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233892AbjLDPA5 (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Mon, 4 Dec 2023 10:00:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233714AbjLDPA0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); 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 20681C4; 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=u3xu4cWioGlm/0Nl4ZRtWZZdIjjd8j62hC7w6zJEnu8=; b=BXioIzqWWZVqflIdLOZVfL3wsh kUWD6QQHc6NI05ep0LckFWjzn50oMDsM0rj1Cv+iUKUaiDciMxW3HG8uWvw0/rWat1sZAdhO3CRp7 Qq7EnjH2a0dNuTdOK6TgXjAicPHkmPHSXn2aLTflELtDsOdkhikEWe/y+JoJ1fCvRPyk=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from <paul@xen.org>) id 1rAAQk-00043d-N8; 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 <paul@xen.org>) id 1rAABc-00088g-03; Mon, 04 Dec 2023 14:44:40 +0000 From: Paul Durrant <paul@xen.org> To: Paolo Bonzini <pbonzini@redhat.com>, Jonathan Corbet <corbet@lwn.net>, Sean Christopherson <seanjc@google.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>, David Woodhouse <dwmw2@infradead.org>, Paul Durrant <paul@xen.org>, Shuah Khan <shuah@kernel.org>, kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v10 19/19] KVM: xen: allow vcpu_info content to be 'safely' copied Date: Mon, 4 Dec 2023 14:43:34 +0000 Message-Id: <20231204144334.910-20-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 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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 04 Dec 2023 07:01:31 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784363987804049581 X-GMAIL-MSGID: 1784363987804049581 |
Series |
KVM: xen: update shared_info and vcpu_info handling
|
|
Commit Message
Paul Durrant
Dec. 4, 2023, 2:43 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) there needs to be 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). 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, 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> Reviewed-by: David Woodhouse <dwmw@amazon.co.uk> --- 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 v8: - Update commit comment. 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 7109d20a4608..72a19956d052 100644 --- a/arch/x86/kvm/xen.c +++ b/arch/x86/kvm/xen.c @@ -1790,9 +1790,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;