From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C225C61D9B for ; Wed, 22 Nov 2023 10:55:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235129AbjKVKzz (ORCPT ); Wed, 22 Nov 2023 05:55:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234991AbjKVKzl (ORCPT ); Wed, 22 Nov 2023 05:55:41 -0500 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C9F19E; Wed, 22 Nov 2023 02:55:35 -0800 (PST) Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2c87adce180so45605041fa.0; Wed, 22 Nov 2023 02:55:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700650534; x=1701255334; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:organization:references:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:from:from:to:cc:subject:date:message-id:reply-to; bh=PDj4B8tTKHknHxb5LSqmGL6/2c2RSafLpktnB37g/4s=; b=HL/0JAtjo0yLGYjma9U8XwcOXHuL18Hd+WHL33V99kWnb0DiY+Wh3t54xsmr9c24fW 5gTZx06IPFaJpeD6XgMYZ0wkxz4MbMzPoxnfrGrHV0wwDNTxfuVKLxkckM4PG6uEiS2R 6oCHwDuUtEsEBhETdaRKULM9R/AteByH8RtMYKU5UHMiIzEb8uDNIkhtTVf79dR51wVX AVa0HYCU3HKgNIQKHy7NRy7fzbhRIJseQ7o8d2UcwpXo60CH+RVrTO9Au3ihGs2a3OBP wiae3kzTqgnH7AE/JLeUt2Qyv+XmDBoOaMjN7w++b06/CB+1jlmrwcfGl2upXFnl+iPV BIlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700650534; x=1701255334; h=content-transfer-encoding:in-reply-to:organization:references:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=PDj4B8tTKHknHxb5LSqmGL6/2c2RSafLpktnB37g/4s=; b=Ucw2q2j//mzMO479Do0SyOgS6XtdQSpk2EfTXa0A9OvKVNeceoLRitGK9jwQCKIAkk 9lHO3Rk+9QAr8X251FKYjtjA/uz5lUgMveiHCoRV0NYXMcx24f0bGEjBBLTxTXsXe0TK +8D+E5UgsFSo2iZSO08x3xjfqHxbfvVJWoFSfiFgb/cRf4N8z7tNgz1kGNjy8fIxNvf4 i4JCzS8a7SpnMBYf/igeiWfbuenUsl9z6OEkGsjJXDtXTjDx2KXAiU7Al0tufangwVGn P99fWlmHldTFKH2jOwyS9Epj/843qI1ep/6alniofj4sp0DdAEiXOhKQh5s6qr6J3aJm w9rg== X-Gm-Message-State: AOJu0YwRD2wTLjI+QuJ3SqpsX82WSPELotr2iLnHVgCuktW85pWXY1Lz KQ+V13h94oHSjAuM/rLmCzg= X-Google-Smtp-Source: AGHT+IHnbvXvm8EJIvq93WQO/F7f6niG7Cc+eqUmPP4FrhRHF/fZxfAVe7xF7vnquqfdMCmL5tqvUQ== X-Received: by 2002:a2e:8e68:0:b0:2c6:ed5e:bbf0 with SMTP id t8-20020a2e8e68000000b002c6ed5ebbf0mr1251662ljk.34.1700650533262; Wed, 22 Nov 2023 02:55:33 -0800 (PST) Received: from [10.95.134.92] (54-240-197-234.amazon.com. [54.240.197.234]) by smtp.gmail.com with ESMTPSA id v9-20020a05600c444900b0040836519dd9sm1835991wmn.25.2023.11.22.02.55.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Nov 2023 02:55:32 -0800 (PST) From: Paul Durrant X-Google-Original-From: Paul Durrant Message-ID: <94697586-7600-420d-a91b-2829019dab7c@xen.org> Date: Wed, 22 Nov 2023 10:55:30 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Reply-To: paul@xen.org Subject: Re: [PATCH v8 15/15] KVM: xen: allow vcpu_info content to be 'safely' copied Content-Language: en-US To: David Woodhouse , 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 References: <20231121180223.12484-1-paul@xen.org> <20231121180223.12484-16-paul@xen.org> <4a76b7dc9055485d9e2592b395e60221dc349abf.camel@infradead.org> <7c7238a9c8b0dc6bc865407ba804a651cdfdb044.camel@infradead.org> Organization: Xen Project In-Reply-To: <7c7238a9c8b0dc6bc865407ba804a651cdfdb044.camel@infradead.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22/11/2023 10:39, David Woodhouse wrote: > On Tue, 2023-11-21 at 22:53 +0000, David Woodhouse wrote: >> On Tue, 2023-11-21 at 18:02 +0000, Paul Durrant wrote: >>> From: Paul Durrant >>> >>> 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 >>> Reviewed-by: David Woodhouse >> >> Wait, didn't we realise that this leaves the bits set in the shadow >> evtchn_pending_sel that get lost on migration? >> Indeed we did not, but that's not something that *this* patch, or even this series, is dealing with. We also know that setting the 'width' of shared_info has some issues, but again, can we keep that for other patches? The series is at v9 and has already suffered a fair amount of scope-creep. Paul