Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp3102775lqt; Tue, 23 Apr 2024 10:17:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV9s/bksNmpSd/+YQyNtkdXtxZ+mL6RXYcYESEFbmUwoHyI5FpHFU39lqwnWBDDp/sg3givXgmfbDNoOskErCZQaqmZwdtZmpZiaqMwfw== X-Google-Smtp-Source: AGHT+IH1Wzya8+bPv3Q8/WqByuya2djUPvNNgl1/GL0O4uTTYt/gU44m0sGRui6rmntYvYnWdz2D X-Received: by 2002:a17:902:ea11:b0:1e0:b2d5:5f46 with SMTP id s17-20020a170902ea1100b001e0b2d55f46mr106171plg.46.1713892677714; Tue, 23 Apr 2024 10:17:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713892677; cv=pass; d=google.com; s=arc-20160816; b=RQetfKhTTOWnqzPHOUlupZo7l+s/Gcrru2XWvK7WfCM6SETZB4BRE69HaXrSVsB/f5 2CyHawg+Gj4u9lKVX+sJS0ldKfoT2uC6nnGczjG6nP7u7kAvg15DBD5lJi5tAujxN2Pg YB5PXrPHmJdsXCvvyG0iW3VxfwpqAyx6MukjvssVcocUW2Gbqy2Eb00bObhoBKoHIVCf /uEsn5lFChrsn/163Bwo3AsdeAFIAiu9BCmvzBopKIrWi7189cLHS7VVhXhyHP8oFoEM 0llkVbXz+UWYYzbFkf07cZXgu8LtbRCOaUIQbQchzJbeOn5KFXMIAhbfkRArg/JhAIe3 Dm6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=qrMyODaSgQui+9iAVFN6vlaX5Jt3U64scBCxMNQkXhg=; fh=94Ec58UOYopFr8YRv6sSG7/vl4sgemZd3tBYtuxEN9o=; b=K5CM28udxffS4ADzNETMMQ7gxQ5xJCO6bvAjUsBRnDD1lAr1l2PdoHIaGODXkZdEFA iq2JpnvIcgqgFYOT7R20V6VqE95Ud+X7Y7Du8lTYEfQQynPjUXFy73xRIR8sOsa2CWDH B84XtNyXJT+Qib9pq5ufOGsjMKYbzuDfmp5ZcxVvhOZwFJzjZRt2xsu53RG0BqqLVu/S BH/nx0PU3erQsvLTx9eHhCMMkBu5ng7uTbnP1XX58wJm9PVVaV/fo6my0xf6J9RQ4Idj U6xS4aWm/sXyIkAdSR201KjGg0EvqA1cq+EoE4ki8KbbQNBKi5/dmcJUDyBs8RpHKmVX cnfA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=K+LX6t7S; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-155142-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155142-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d5-20020a170902654500b001e41c8728f2si9537438pln.1.2024.04.23.10.17.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 10:17:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155142-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=K+LX6t7S; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-155142-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155142-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 17FBD281A76 for ; Tue, 23 Apr 2024 12:14:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A172A134420; Tue, 23 Apr 2024 12:13:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="K+LX6t7S" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 1036713343F; Tue, 23 Apr 2024 12:13:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713874424; cv=none; b=j10iTS7iSvGTBTWLX0Q6HBWMlet0W6DE8BgLZEIfvfjM1NeqOAdeg3WDA6w85MOMtVAcXBhf42bbVzsGOCPf469dhmR7Q2tQco3xr0A/vCmC46xOCQpTayNmwq+gxARNyE0SB2do6A3IWsVNJp3RTP3qOmhzGB8g3ZdGGN3n3wU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713874424; c=relaxed/simple; bh=ArWUw6uKt2yghFGqp2E1p2fxhgfr7jktAJfVc5O/ej8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=K8rIguTbsmCLB5R8YMNrq+pi21VOrkrTor3xLgb3dJhKz77Wsuga8Hh/SUSPpG+1Hpl3zkhSmCvH4e7Qe5PQZCEN8qi0w5N5ysSG+1J+Z/I7rQStRFBPalAd5pVNUrcJJU38SOoVav/F/2iz3MdSZpFBMo0PTiy++NWvbFXrELc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=K+LX6t7S; arc=none smtp.client-ip=192.198.163.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713874423; x=1745410423; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=ArWUw6uKt2yghFGqp2E1p2fxhgfr7jktAJfVc5O/ej8=; b=K+LX6t7SVpX2TVDcPuFstwfkK34WrL52gw3br0xZ5WglJb0CV5upEuOv 571O4gheuCumKKUlqFRyBDW0W6MgsuhVQqSB37yo8xAXbs3WQSk+HGUGL yAZoTGdYt/kebOH4hS5Ae8fqO9fNlQDgaArL/kvbP38G45D1Rx2OAtYBL A3JuEqvTOKqV66kDWH7a3GKJtJzuBAKZKMQGg7GmfN6qICKTqPz1/TscW velNAduwIaNgGPiDwzMz8R07ihRPMgRegHKRG9iCAQDoWdf8LN2Cpm3/Z bon5nSMT+j9+ZpXpzOb+63Fj2MPgFAfA4Hnv8186f0auQbMEegiU0jv01 g==; X-CSE-ConnectionGUID: GuXjhNoBTQ+5mt0ZQIwt9A== X-CSE-MsgGUID: wJswtA5YTKiSFXbrWDYNtg== X-IronPort-AV: E=McAfee;i="6600,9927,11052"; a="9307643" X-IronPort-AV: E=Sophos;i="6.07,222,1708416000"; d="scan'208";a="9307643" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2024 05:13:31 -0700 X-CSE-ConnectionGUID: liVSNiqCTP6hqDIQ5KOxDg== X-CSE-MsgGUID: Gtizr1bARWKmSVoJMgvv8Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,222,1708416000"; d="scan'208";a="55305704" Received: from binbinwu-mobl.ccr.corp.intel.com (HELO [10.124.225.183]) ([10.124.225.183]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2024 05:13:28 -0700 Message-ID: <01988152-c87b-4814-adc5-618e31fc035e@linux.intel.com> Date: Tue, 23 Apr 2024 20:13:25 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v19 087/130] KVM: TDX: handle vcpu migration over logical processor To: Reinette Chatre , isaku.yamahata@intel.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com References: <0c3efffa-8dd5-4231-8e90-e0241f058a20@intel.com> From: Binbin Wu In-Reply-To: <0c3efffa-8dd5-4231-8e90-e0241f058a20@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/13/2024 12:15 AM, Reinette Chatre wrote: > Hi Isaku, > > On 2/26/2024 12:26 AM, isaku.yamahata@intel.com wrote: >> From: Isaku Yamahata > ... > >> @@ -218,6 +257,87 @@ static void tdx_reclaim_control_page(unsigned long td_page_pa) >> free_page((unsigned long)__va(td_page_pa)); >> } >> >> +struct tdx_flush_vp_arg { >> + struct kvm_vcpu *vcpu; >> + u64 err; >> +}; >> + >> +static void tdx_flush_vp(void *arg_) >> +{ >> + struct tdx_flush_vp_arg *arg = arg_; >> + struct kvm_vcpu *vcpu = arg->vcpu; >> + u64 err; >> + >> + arg->err = 0; >> + lockdep_assert_irqs_disabled(); >> + >> + /* Task migration can race with CPU offlining. */ >> + if (unlikely(vcpu->cpu != raw_smp_processor_id())) >> + return; >> + >> + /* >> + * No need to do TDH_VP_FLUSH if the vCPU hasn't been initialized. The >> + * list tracking still needs to be updated so that it's correct if/when >> + * the vCPU does get initialized. >> + */ >> + if (is_td_vcpu_created(to_tdx(vcpu))) { >> + /* >> + * No need to retry. TDX Resources needed for TDH.VP.FLUSH are, >> + * TDVPR as exclusive, TDR as shared, and TDCS as shared. This >> + * vp flush function is called when destructing vcpu/TD or vcpu >> + * migration. No other thread uses TDVPR in those cases. >> + */ Is it possible that other thread uses TDR or TDCS as exclusive? >>