Message ID | 20240115125707.1183-20-paul@xen.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-26001-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1692311dyc; Mon, 15 Jan 2024 05:12:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWWw7QwyMlXRdpG+VKNG77jE75fg4gT24qQDRHz0nBmj+oE5YStdt+++6bZVEC2cG2Z1cZ X-Received: by 2002:a17:907:a78a:b0:a2d:359b:b880 with SMTP id vx10-20020a170907a78a00b00a2d359bb880mr1801156ejc.13.1705324325469; Mon, 15 Jan 2024 05:12:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705324325; cv=none; d=google.com; s=arc-20160816; b=g+tS0KwazCBwRKHo2VXJTFCtlGyGVvLxKYte+7pMuNtol24IGAwrXA88PKbHO0HsNs 12z1tygLSvaZ3SlQPs6tsqAi86nHNt/guiC0sXvloQFT75rotLV1jSsumTZOzxkIUwM0 i7wbeG8GqLWfRTRrEGz9UAVncBzHsaeBEpCLG/bIZYP8rhAMdkz9mwIu7cQzvCTjju+H M2q+vi1Rxik6PCjMAF2uAm6d0TtOAus6PxIzNMODdmdyd8M1UlQV09lQihr1AwsxH5qU pySVZYBNFDU2Y77JElsQUL5YGkhH2MRBuOQkCV+fpndcNz0McEVbGaa3XnUH1saILP/5 Xiew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=5P2JtCeSZO2zn4VBkHCTT9EEqwZefcJCWgY3hftSny4=; fh=aAPqvXm40pY9772UiBOljEePwtz/3Q0zIOpw238tj3M=; b=sA7L2FbOoeZe3QIajPTWI10946kaGEX2T4aVwVlCcCmNmP0nbzkthXtp8ja8hKuhIO 10tJsDAMLFIp+POvmbwsV+xNNHc1BIfd2r9vSylsKF/jforCTA+p46bkux3Lvc49MX0f 7RIqC/WXyLpTAseB9jYdGTSGOQgJ1SWpLyrbpC2gsnKW694GcvaEHCK9oZGeGv2ga3+h s5Z3NCI83Ev1yEl9ut9/b55kCTx5q2Y1+EWoxgUmjACi8sCRPKsVW8Qf0zmfLV9BxQQ9 ElbUzaj5GhUq5nSFnYr8T4+h7ZxGGoSbhu2JbKJa8cVFEQjdK0+B3sEI3hq2VBee+FbY /J1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b="V/caNzGA"; spf=pass (google.com: domain of linux-kernel+bounces-26001-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26001-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id e27-20020a170906045b00b00a236b237296si3761644eja.391.2024.01.15.05.12.05 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 05:12:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26001-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b="V/caNzGA"; spf=pass (google.com: domain of linux-kernel+bounces-26001-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26001-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1885E1F223AA for <ouuuleilei@gmail.com>; Mon, 15 Jan 2024 13:12:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80B6517C6D; Mon, 15 Jan 2024 13:09:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xen.org header.i=@xen.org header.b="V/caNzGA" Received: from mail.xenproject.org (mail.xenproject.org [104.130.215.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24C8017566; Mon, 15 Jan 2024 13:09:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xen.org 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=5P2JtCeSZO2zn4VBkHCTT9EEqwZefcJCWgY3hftSny4=; b=V/caNzGAWaZDOBgEe5DDitmoiI v9XSah+J0bkMcpgftR6Wp/2ATTnlt/Pnjr7BNcDYMmkQ+WEz8uOTlIIA/CYWo+BOtoDOE4w9rPqHP W7iaaDgmlh6M0geahSO0wJ/HU1Oe14W9bIGimE1UJnLb59TsDGR+wz6rQzFApTHnv4BA=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from <paul@xen.org>) id 1rPMiZ-00035q-6D; Mon, 15 Jan 2024 13:09:31 +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 1rPMXi-0002kM-4r; Mon, 15 Jan 2024 12:58:18 +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 v12 19/20] KVM: xen: allow vcpu_info content to be 'safely' copied Date: Mon, 15 Jan 2024 12:57:06 +0000 Message-Id: <20240115125707.1183-20-paul@xen.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240115125707.1183-1-paul@xen.org> References: <20240115125707.1183-1-paul@xen.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788162160031916167 X-GMAIL-MSGID: 1788162160031916167 |
Series |
KVM: xen: update shared_info and vcpu_info handling
|
|
Commit Message
Paul Durrant
Jan. 15, 2024, 12:57 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 9168a6ec88fd..972098ec4f6a 100644 --- a/arch/x86/kvm/xen.c +++ b/arch/x86/kvm/xen.c @@ -1797,9 +1797,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;